Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Customize form success message via code in forms 5.7.x


Hi all,

We had logic to add a custom link to the success submission message based off the example here:

This however, has been broken with the latest form package that is required to fix a vulnerability.

The code still executes. You can see the default message with the [[PDF]] token that should be replaced.

And I can see the message being updated with the PDF url before being sent to the base.BuildReturnResultForSubmitAction

However, only the initial message is displayed, ignoring the updated value via code:

Is this a bug or is there a new way to do this in the latest version of forms?

Edited, Nov 15, 2023 19:39

Hi Julio Canadas

I've tried to add a custom message like you did, and it still works for me. You can see it here:

Could you provide your full custom code, so that we can investigate more?

Nov 17, 2023 1:43

Hi Manh,

We must be doing something differently. I setup a blank net core alloy sample and it is still not replacing the value:

Let me know how I can send code over.

Dec 01, 2023 18:19

Hi Julio Canadas

Please send your code and your issue details to, or submit this form Then we will create a support case to investigate it.

Thank you!

Dec 04, 2023 1:53

Just in case it helps anyone else, this was a change that was introduced in forms 5.6.0.

Support replied with the following:

Because the message is now pre-render on DOM, the client can utilize client-side script to change the success message based on submitting data.

var $form = $('.EPiServerForms:eq(0), [data-f-type="form"]:first')
$form.on("formsSubmitted", function (e) {
    // Logic to get the success message and replace with data here

Noted that the FormData in the event args is a type from the browser which already serialized so you have to parse to a request to view it.

When looking at the json object of the formsSubmitted, it still contains the code replaced message. It's just not replacing the final html.

Our solution was adding the following script to the page:

<script type="application/javascript">
    window.addEventListener('load', (event) => {
        if (typeof $$epiforms !== 'undefined')
            $$epiforms(document).ready(function myfunction()
                $$epiforms(".classOfFormContainer .EPiServerForms").on("formsSubmitted",function(e)
                    //get successMessageElement
                    var successMessageElement = document.querySelector('#Success__Message__' + e.workingFormInfo.Id);

                    //replace successMessageElement html
                    successMessageElement.innerHTML = e.returnedResult.message;


This will replace the success message html with the code generated one that has the token replaced.

Dec 15, 2023 17:54
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.