Redirect to different locations when submitting EditForm

Forums Dynamic Forms for SharePoint Redirect to different locations when submitting EditForm

This topic contains 3 replies, has 2 voices, and was last updated by  Alexander Bautz 2 months, 4 weeks ago.

  • Author
    Posts
  • #17259

    Říha Michal
    Participant

    Hi Alexander,
    I have these buttons in EditForm:

    
    
    <input id="btnAction1" class="customBtn" type="button" value="ACTION1" onclick="fnAction1();return false;">
    <input id="btnAction2" class="customBtn" type="button" value="ACTION2" onclick="fnAction2();return false;">
    <input id="btnAction3" class="customBtn" type="button" value="ACTION3" onclick="fnAction3();return false;">
    <input id="btnAction4" class="customBtn" type="button" value="ACTION4" onclick="fnAction4();return false;">

    each button fill different values to form and call submit.
    Is it possible redirect user to different locations (different views) after submitting depending on which button was use?
    Is it possible to change Source= parameter in url?

    I tried to add this line

    $(location).attr('href', 'https://sharepointtest/sites/DocLibraryTest/Forms/NOK.aspx');

    it is working, but when there is some error in form at submitting (eg missing required field) – form is redirected immediatelly without possibility to correct form.

    Many thanks

    Michal

  • #17327

    Alexander Bautz
    Keymaster

    Hi,
    You can use this snippet in each of your functions:

    spjs.dffs.redirect("TheRedirectURL",false);

    Let me know how it works out.

    Alexander

  • #17418

    Říha Michal
    Participant

    Hi Alexander,
    it is not working – no redirection is done.
    Michal

  • #17437

    Alexander Bautz
    Keymaster

    This should work by setting the redirect-on-save to the new URL, but the actual redirect will only happen when the form is actually saved (using the default button).

    If you like your custom button to set the redirect URL and save the form you need to add one line to your function to “click” the default save button.

    I’ll have to see your current code to see how you “submit” the form to be able to help you further because my code example only works with the default save button and not with any custom submit function.

    Alexander

You must be logged in to reply to this topic.