3

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
  • 1
    What sitecore version do you use?
    – x3mxray
    May 8, 2020 at 12:40

1 Answer 1

1

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;
        }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.