2

I'm using WFFM MVC on Sitecore 8.2 and want to re-direct to the Success Page with some custom querystring parameters.

However looking at Sitecore.Mvc.Forms.config no pipelines are run for MVC.

Therefore most examples I've found for doing this will not work with MVC (only WebForms :-(). e.g: https://ggullentops.blogspot.com/2016/07/sitecore-wffm-act-on-success.html and: https://sitecoretricks.com/2018/02/23/wffm-webfroms-customizing-the-successredirect-pipeline/

I found this answer from Marek Musielak about overriding the entire FormController class but this seems pretty horrible:

https://stackoverflow.com/questions/32924910/overwrite-succesredirect-for-wffm-on-mvc-project

Are they any work-arounds or other approaches for this?

closed as off-topic by Peter Procházka, Mark Cassidy Nov 24 '18 at 0:38

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Peter Procházka, Mark Cassidy
If this question can be reworded to fit the rules in the help center, please edit the question.

0

Adam,

you should check my blog on https://ggullentops.blogspot.com/2016/07/sitecore-wffm-act-on-success.html. You say you did, but it does mention the solution for MVC, even with the code to adapt the redirect url (by adding a querystring, just as you need).

The pipeline you are looking for is <wffm.success> (set in Sitecore.MvcForms.config).

The wffm.success is by default empty. The actual redirect happens in another pipeline later on. So redirecting here is not the right thing to do. When I started writing the processor I noticed had a lot of information in a Sitecore.Forms.Mvc.Models.FormModel.

You have access to all the fields, and to the SuccessRedirectUrl property. At this point this is filled with the url as set in Sitecore (which is very useful as a base) and you can alter it as you please. The actual redirect will happen later but it will use the value you have set here.

Code example:

public class SuccessRedirect : FormProcessorBase<IFormModel>
{
    public override void Process(FormProcessorArgs<IFormModel> args)
    {
        Assert.ArgumentNotNull((object)args, "args");
        var model = args.Model as FormModel;
        if (model == null)
            return;
         model.SuccessRedirectUrl = model.SuccessRedirectUrl + "?val=" + model.Results[0].Value;
    }
 }
  • Your right Gatogordo. This does work, I wasn't patching it in correctly is all. I'll add my code when I get a minute to help others as it's a variation on yours. I think Marek's answer on the link above made me think this wouldn't work with Pipelines but I wasn't doing it quite right. – Adam Seabridge Sep 24 '18 at 19:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.