November Happy Hour will be moved to Thursday December 5th.

Localize or remove error message added to form actor result

Vote:
 

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.

Thanks,

Calvin

#199823
Dec 12, 2018 19:13
Vote:
 

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)
        {
            _logger.Error(msg);
        }
    
        // 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);
    }
}
#199834
Edited, Dec 13, 2018 4:08
Vote:
 

Great. This is just what I was looking for.

Thank you Quan.

#199848
Dec 13, 2018 17:17
Vote:
 

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

#199850
Dec 13, 2018 17:58
Vote:
 

Sorry, had planned on it and got sidetracked.

#199851
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.