WFFM Custom Save Action :- pass response data to thankyou page

715 views Asked by At

I am using WFFM Custom Save action methods. Here I am executing some service and getting response , I have to display response in next page.I used below code but its not working.

internal class WffmCustomSaveAction : WffmSaveAction
{
    public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext, params object[] data)
    {
        HttpContext.Current.Response.Clear();

        StringBuilder sb = new StringBuilder();
        sb.Append("<html>");
        sb.AppendFormat(@"<body onload='document.forms[""form""].submit()'>");
        sb.AppendFormat("<form name='form' action='{0}' method='post'>", "http://local.website/thankyoupage");
        sb.AppendFormat("<input type='hidden' name='id' value='{0}'>", "id123");
        // Other params go here
        sb.Append("</form>");
        sb.Append("</body>");
        sb.Append("</html>");

        HttpContext.Current.Server.Transfer(sb.ToString());
        HttpContext.Current.Response.End();
    }
}
1

There are 1 answers

0
Gatogordo On

You should not use a SaveAction to do the redirect to your thankyou page. You can use the Sitecore pipelines to change the redirect url. A working example can be found here for MVC forms (Webforms pipelines are mentioned as well, but without code example).

All comes down to finding the correct pipelines in Sitecore. In this case you need a pipeline in case of success. But be aware: there is a big difference between the webforms and mvc solution.

Webforms: The pipeline in case of webforms are: <successAction> This can be found in Sitecore.Forms.config.

Mvc: The pipeline in case of mvc are: <wffm.success> This can be found in Sitecore.MvcForms.config.