Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • naitsirhc 15 posts 116 karma points
    Feb 12, 2019 @ 07:49
    naitsirhc
    0

    trying to create a custom workflow.

    Hi, I am trying to create a custom workflow(I am totally lost how to do it), for a form that I have. I want the workflow to be able to redirect the user to a page based on which radiobutton they have selected on the form.

    For example. if the user select the first radio button, they would be redirected to the homepage or if they selected the second button they would be redirected to an external page on submit.

  • Matthew Wise 188 posts 772 karma points c-trib
    Feb 12, 2019 @ 08:11
    Matthew Wise
    0

    Hi Christian,

    Workflows run post submit and the only one that can control user flow is the in built one.

    One way of achieving your goal is to redirect them to a generic success page. Then check the TempData for the submission id a d redirect from there.

    Matt

  • naitsirhc 15 posts 116 karma points
    Feb 12, 2019 @ 08:23
    naitsirhc
    0

    thanks!

    Umm, how would I go about checking the TempData for submission id??

    I'm new to Umbraco and its been a few years since I've written any code, so I am abit rusty.

  • Matthew Wise 188 posts 772 karma points c-trib
    Feb 12, 2019 @ 08:47
    Matthew Wise
    100

    This should allow you to get the Record from TempData.

    var recordService = new Umbraco.Forms.Web.Services.RecordService();
    var record = recordService.GetRecordFromTempData(TempData);
    
    if(record != null){
    //TODO: check and redirect
    }
    else{
    //TODO: handle page load without record data.
    }
    
  • naitsirhc 15 posts 116 karma points
    Feb 12, 2019 @ 10:07
    naitsirhc
    0

    does var record = recordService.GetRecordFromTempData(TempData); give me a collection of every field from the form?

  • Matthew Wise 188 posts 772 karma points c-trib
    Feb 12, 2019 @ 10:08
    Matthew Wise
    0

    Yes it is whats stored in the database.

  • Matthew Wise 188 posts 772 karma points c-trib
    Feb 12, 2019 @ 08:53
    Matthew Wise
    0

    Doing a bit more exploring you can also do it all this way and avoid the intermediary page:

    public class MyFormsController : UmbracoFormsController
    {
         protected override void OnFormHandled(Form form, FormViewModel model)
          {
              //example of how to access fieldData
               var field = form.AllFields.FirstOrDefault(x => x.Alias == "deliveryOptions");
               var fieldValue = model.FormState[field.Id.ToString()].GetValue(0).ToString();
    
               form.GoToPageOnSubmit = <pageId>;
          }
    }
    

    Then replace the Controller with yours in the Form.cshtml

Please Sign in or register to post replies

Write your reply to:

Draft