Try our conversational search powered by Generative AI!

Localize or remove error message added to form actor result


I have created a custom form actor that sends form data to an external service. If the form does not submit successfully to this service I create a SubmissionActorResult object and set it to cancel submit and add an error message to it. When this result object gets sent back to the form and displays the error on the form page it has an additional error messege prepended to the one I wrote to the result object. It always adds "Failed to submit." In front of the error message That I wrote. 

I can't find where this message comes from. I would like to remove it or at the least localize it but I can't find how to do this.



Dec 12, 2018 19:13

You can override method BuildReturnResultForSubmitAction in DataSubmissionService as below and register dependency in initialization module. It should work.

public class CustomDatasubmissionService : DataSubmissionService
    protected override SubmitActionResult BuildReturnResultForSubmitAction(bool isJavaScriptSupport, bool isSuccess, IEnumerable<string> errorMessages, HttpContextBase httpContext,
                                            FormContainerBlock formContainer = null, Dictionary<string, object> additionalParams = null, SubmissionInfo submissionInfo = null,
                                            Submission submission = null, bool isProgressiveSubmit = false, string redirectUrl = "")
        var message = string.Join("<br/>", errorMessages);
        foreach (var msg in errorMessages)
        // the default behavior, that's why an additional message was added
        //return BuildReturnResultForSubmitAction(isJavaScriptSupport, false, LocalizationService.GetString("/episerver/forms/messages/formsubmission/submitnotsuccess") + message, httpContext, formContainer);

        // don't add an additional message
        return BuildReturnResultForSubmitAction(isJavaScriptSupport, false, message, httpContext, formContainer);
Edited, Dec 13, 2018 4:08

Great. This is just what I was looking for.

Thank you Quan.

Dec 13, 2018 17:17

If someone answers your question, please click the Mark Answer button. Thank you.

Dec 13, 2018 17:58

Sorry, had planned on it and got sidetracked.

Dec 13, 2018 18:00
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.