Copied to clipboard

Flag this post as spam?

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


  • Christian 10 posts 81 karma points
    4 days ago
    Christian
    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 150 posts 577 karma points c-trib
    4 days ago
    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

  • Christian 10 posts 81 karma points
    4 days ago
    Christian
    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 150 posts 577 karma points c-trib
    4 days ago
    Matthew Wise
    0

    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.
    }
    
  • Christian 10 posts 81 karma points
    4 days ago
    Christian
    0

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

  • Matthew Wise 150 posts 577 karma points c-trib
    4 days ago
    Matthew Wise
    0

    Yes it is whats stored in the database.

  • Matthew Wise 150 posts 577 karma points c-trib
    4 days ago
    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