November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hi Sam,
You were probably better off starting a new thread opposed to dredging up one that was this old!
Regardless, you can't use the FormsSubmissionFinalized
event. What you'll need to do is add a custom DataSubmissionService (EPiServer.Forms.Core.Internal) implementation and override the BuildReturnResultForSubmitAction
method, as per this example:
public class CustomDataSubmissionService : DataSubmissionService
{
protected override SubmitActionResult BuildReturnResultForSubmitAction(bool isJavaScriptSupport, bool isSuccess,
string message, HttpContextBase httpContext, FormContainerBlock formContainer = null,
Dictionary<string, object> additionalParams = null, SubmissionInfo submissionInfo = null,
Submission submission = null, bool isProgressiveSubmit = false, string redirectUrl = "")
{
if (!string.IsNullOrEmpty(message))
{
message = $"{message}<p>Example.</p>";
}
return base.BuildReturnResultForSubmitAction(isJavaScriptSupport, isSuccess, message, httpContext,
formContainer, additionalParams, submissionInfo, submission, isProgressiveSubmit, redirectUrl);
}
}
You can easily switch out the default implementation:
[InitializableModule]
public class FormsInitialization : IConfigurableModule
{
public void ConfigureContainer(ServiceConfigurationContext context)
{
context.ConfigurationComplete += (o, e) =>
{
context.Services.AddSingleton<DataSubmissionService, CustomDataSubmissionService>();
};
}
public void Initialize(InitializationEngine context)
{
}
public void Uninitialize(InitializationEngine context)
{
}
}
This will append "<p>Example.</p>" to the end of your success message (regardless of the form or the message) but it hopefully gives you enough to get started.
Hi,
I need to customise the "Display message after form submission" displayed to a user after submitting a form using EPiServer Forms. I have a message set already and I need to add a unique reference number to this message for the user once the form is submitted.
I see there is a DataSubmissionService which has a FormsSubmissionFinalized event, is this the best thing to use? If so, how do I implement this? I can't see anything obvious. Are there any other approaches?
Thanks in advance,
Mark