I have three save actions on a WFFM form. If some error occurs in first save action then i don't want other two save actions to be executed. Can anyone please suggest how i can achieve that.
1 Answer
I have used the following in 9.1:
On the FormSubmitContext class, you can use the Canceled property to check to see if you should do some work. If you have run into a case where you don't want your processing to continue, you can use the Abort() method, which will set Canceled to true.
public class MySubmitAction : SubmitActionBase<MyModelData>
{
public MySubmitAction(ISubmitActionData submitActionData) : base(submitActionData)
{
}
protected override bool Execute(MyModelData data, FormSubmitContext formSubmitContext)
{
if (formSubmitContext.Canceled)
return false;
bool somethingWrong = false;
// Do some work here.....
if(somethingWrong)
{
formSubmitContext.Abort();
return false;
}
return true;
}
}