Solved

Redirect URL when user clicks Cancel Button

  • 2 February 2015
  • 15 replies
  • 554 views

Hello -

 

I know it's possible to redirect users when the form has been submitted to a custom URL, but does any know if it's possible to redirect users when they click the cancel button?  We have a form linked in a central library and would prefer to keep them out of the source list which is what is presented when they cancel the form.

 

Any suggestions and help will be appreciated.

 

Thanks!

 

Jason

icon

Best answer by xMikeX 3 February 2015, 21:25

View original

15 replies

Userlevel 5
Badge +12

Hi Jason,

You can easily do this by changing the Cancel button into a JavaScript button within its configuration, and writing a small JS function for it to call that redirects to the desired page.

Thanks

Thanks Mike.  That's actually what we ended up doing after a little more research.  Initially it wasn't obvious to us that we could update the button action, but after we discovered that, we were good to go.

Hi Dlyva,

These are the steps we took to accomplish the goal:

Form

  1. Expand the custom JavaScript section in form settings. 
  2. We did something really simple and added the following:  function doRedirect(){history.go(-1);}

Form Settings.png

Cancel Button

  1. For the cancel button behavior, we changed the default button action from Cancel to JavaScript.
  2. In the control settings window for the cancel button we expanded the Advanced section and added the following the Client Click field:  doRedirect();
  3. We saved changes and that did the trick for us. 

Control Settings.png

It's really simply but it let us return the user to the screen previous without worrying where the form link was referenced.  Not sure if there's a better or different way, but I'm sure you can get pretty creative here depending on your requirements.

Cheers,

Jason

We are having this same issue, but our users are launching the form from an email that we provide them, therefore the history.go(-1) does not work for us. I tried so many variations of the following JavaScript but none seemed to accomplish what we wanted:

window.location.href = "http://www.Nintex.com";

window.location = "http://www.Nintex.com";

window.location.replace("http://www.Nintex.com");

We ended up using window.top.location.href= "http://www.Nintex.com";

There were two other ways to accomplish this, though, that we discovered during testing. The first was to pass in the query string variable Source=http://www.Nintex.com on the end of our Edit item link in the email, which worked.

We also created a label that had a hyperlink to the redirect page. We put the display name as Cancel and styled it to look like a button.

Hope this helps!

Sabrina

Badge +4

I followed this step but it didn't work for me.... What I found was in my function I had to use a single quote mark rather than double...

eg: function doRedirect(){

window.top.location.href='http://www.Nintex.com');

}

Not sure if anyone else came across the same this but worked once i changed " to '

Thanks for the help!

Userlevel 5
Badge +13

Hey Mike,

Is there any way to change this for the Cancel button in the ribbon and/or disable/hide the cancel button in the ribbon? I have the form redirect set to my url (so on save it goes where I want) and I've modified the JS ont he cancel button on the form to redirect to my url (and that works). But if the user clicks the cancel button in the ribbon, it goes to the list AllItems view (save button in ribbon redirects correctly). Any way to address this?

Badge +4

Courtney Vargo‌,

Not sure if you fixed your issue, but I have a pseudo solution you might be interested in.

I have completely hidden the ribbon in all of my forms and have created buttons for the user to press either save / submit buttons or cancel / close, similar to what you mentioned.

You can use the Nintex Form jQuery to hide the cancel button, in your custom form javascript you'll need to add

NWF$('#RibbonCloseButton').hide();

Badge +3

Needed a solution for this and found your comments. Nintex is meant to be a good tool for non programmers. Use of Java script or query is not in my repertoire. This should be the same as the rest of Nintex, an option. Having said that thanks for the help, i will give it to one of our developers. (something I did not want to do  )

Userlevel 5
Badge +13

Hey Cy Marven, when this post was made the JS was the only option. Now, however, forms have updated! Each button has its own redirect URL available in the settings. 

Let me know if this works out for you!

Badge +3

Hi  Courtney Vargo‌. I realise this works for buttons you add. I am looking to do this for the cancel and save  button in the ribbon.

Userlevel 5
Badge +13

Hey Cy Marven, I just tested it and it effects the ribbon button as well. As in, whatever I set as the redirect URL for the "cancel" button on the form also is the redirect URL used by the ribbon Cancel button. Are you not seeing this behavior?

Badge +3

Got quite excited for a minute, however if I set the URL for redirect on button it only works there. I failed to mention I am using the responsive form. Does this make the difference I wonder?

Userlevel 5
Badge +13

Hmm, odd, I get the same behavior in classic and responsive form, whatever I set as the cancel redirect for the button also modifies the ribbon. I also added an additional Cancel button (leaving the default one) and set a different redirect URL. Now my ribbon button does the second cancel button's redirect URL (this is on responsive form) even though I left the first cancel button, the default one, at a different redirect URL.

Do you have multiple cancel buttons? If so, do they all have the same redirect URL?

Badge +3

Courtney Vargo‌. Thank you so much for your patience . I created a cancel button as missed the fact there was already one at the bottom of the form, doh! I have now deleted the one I created and changed the redirect at the bottom of the form, guess what? It works! Again thank you very much.

Userlevel 5
Badge +13

Happy to have been of assistance! Glad you got a no-code solution  

Reply