cancel
Showing results for 
Search instead for 
Did you mean: 
annaflambergcot
Nintex Newbie

Button - Save and Redirect

Jump to solution

I added a button to my form IT General Controls. When the user clicks that button I would like to save my current form and redirect the user another URL. I set up my button following another post but its not working. My button configurations are below. Any help would be greatly appreciated.

Reply
12 Replies
tomaszromanski
Nintex Newbie

Re: Button - Save and Redirect

Jump to solution

Hi,

There are, as always, several options to achieve that.

The simplest one in this case is to use the normal save button (Button action: Save), and sets the redirection URL in form settings?

Nintex_RedirectURL.PNG

Reply
annaflambergcot
Nintex Newbie

Re: Button - Save and Redirect

Jump to solution

Hi Tomasz,

Thank you, that would work if I only have 1 button but I need to add multiple buttons. Each should save the current form and go to a different URL. Any more ideas?

0 Kudos
Reply
tomaszromanski
Nintex Newbie

Re: Button - Save and Redirect

Jump to solution

Hi Anna,

OK, then try the following option:

Below are 3 JavaScript buttons [No. 2], 1 Save button [No. 1] and 1 Cancel button.

Save button is hidden by the css class 'saveButton' [No. 1B] ->Settings-Form -> Custom CSS -> .saveButton {visibility: hidden;}

NintexDemo1.JPG

All JavaScript buttons [No.2] have their own Client click function. Below an example of the settings for button "Save & Redirect 1"

NintexDemo2.JPG

Finally, the functions -> Settings-Form -> Custom JavaScript

NintexDemo3.JPG

I tested everything and it works as desired. Have fun trying it out.

Reply
Not applicable

Re: Button - Save and Redirect

Jump to solution

I'm trying this JS for my own Save & Redirect button (just one button on the form) but can't seem to get it to work. It is redirecting to another page within the same SharePoint 2013 site.

With the below data, when I click the Save button the form re-freshes but retains the details I entered/selected and doesn't save anything. Can you tell me what I'm doing wrong?

Reply
tomaszromanski
Nintex Newbie

Re: Button - Save and Redirect

Jump to solution

The save button (no. 1 in my previous screenshots) is mandatory for this proposal, but can be hidden with css (see again my suggestion). JavaScript functions are defined with the function keyword and all JavaScript identifiers are case sensitive.

Your solution should look like:

function SaveAndRedirect()

{

NWF$('.saveButton').click();    //the css class references the normal save button (no.1) and triggers a click-event on it

window.location.replace('https://sites.....');

}

So you need 2 buttons, one with an action 'Save' and CSS class 'saveButton' and one with button action JavaScript.

Reply
Not applicable

Re: Button - Save and Redirect

Jump to solution

Thanks Tomasz,

Rookie error on my part.

Do you know if there's a way to set up a SaveAndRedirect button without having to have 2 buttons?

Going to give the above a try now.

e: I saw your first reply to this post about simply setting up a redirect URL under the general form settings. I originally tried that but couldn't get the redirect URL to work in the first place but I then also realised that it would (probably) also mean when the cancel button was clicked the form would redirect to the same page which I don't want as the redirect target is a 'Thanks & Next Steps' page.

0 Kudos
Reply
Not applicable

Re: Button - Save and Redirect

Jump to solution

Hey Tomasz,

I was finally able to get the re-direct function to work but I can't get the form to actually save before redirecting. Can you tell me what I'm missing?

CSS button:

JS button:

Settings - Form

0 Kudos
Reply
annaflambergcot
Nintex Newbie

Re: Button - Save and Redirect

Jump to solution

Hi Tomasz,


Thank you, thank you, thank you. It works perfect!!

I have 1 more question, I have 10 buttons so the 10th has -  saveAndRedirect10()   as the Client Click. It's the only button that doesn't save. Could it be because it has a double digit number instead of single?

0 Kudos
Reply
courtney_shelto
Nintex Newbie

Re: Button - Save and Redirect

Jump to solution

Hey Tomasz,

I have implemented your solution and it works great! The only issue is that we have some required fields on our form, and when you click, it quickly highlights them in red to say "you must have these filled out," but then the redirect carries through anyways. So the item is not submitted because there are required fields not filled out, but the redirect occurs. How to address this?

P.S. We are not redirecting to a specific URL, we're going history.go(-1) so my full JS function is:

function saveAndRedirect()
{
NWF$('.saveButton').click();
history.go(-1);
}

Reply