Nintex forms custom button submit AND redirect

  • 18 December 2014
  • 16 replies
  • 115 views

Badge +3


I have a form that I want to use the standard thank you page redirect if the user selects the canned "Save" button.

I also have a custom button that would "save" the current form contents (NewForm.aspx)  and redirect the user to a fresh form to enter another item.

I am having a great deal of difficulty figuring out the javascript to submit and redirect to NewForm.aspx ,  redirect works but submit is not working ....

$(this.form).submit()

window.location.replace("https://************************/sites/SupportRequest/NewForm.aspx");


16 replies

Userlevel 7
Badge +11

If you are using the jQuery library that comes with NF you would need to change your namespace to NWF$ rather than just $ . This blog post briefly talks about it http://sharepointpapers.blogspot.com.au/2013/08/nintex-forms-with-spservices-library.html?m=1

Sent from my Windows Phone

Badge +3

I was actually using just the normal jquery out on google, do I
need to use the nintex version? Is it available on the Nintex site for download?

Badge +6

It's preloaded with the form. You just reference it by another name.

Badge +6

Looks like there might be synchronization issues. Submit is asynchronous, I believe, so when you do the location.replace() you don't give it a chance to complete. Do the redirect only in a callback that should fire after the submit status changes. I don't have all the details on how to do this and whether it's feasible without wrapping OOTB submit into another function, but you should get the idea.

Badge +3

I cannot get a submit to work by itself....

NWF$(theForm).submit()  Does not work

NWF$(this.form).submit()  Does not work

NWF$(document.aspnetForm).submit()  does not work

Straight JavaScript :

document.getElementById("aspnetForm").submit()  does not work  does not work....

What am I missing ?

Badge +9

Yeah I just use a combination of the Source parameter in the link provided to end users and the Redirect URL in form settings, this takes care of both Submit and Cancel.

Badge +3

Ok after a lot of soul searching and my Nintex friends unable to help me,  here is what I did to work around this.

Created a web page as a "thank you for your submission" page and used the redirect function in the Nintex form editor (under advanced) and then on the resulting thank you page I put two buttons, one opens a fresh form and the other sends to you a "thank you, your submissions are complete"

Badge +3


whatever your path is the form itself is NewForm.aspx  so a typical url would look like:

https://mastersite.com/sites/SITENAME/LISTNAME/NewForm.aspx

Badge +3

Can't seem to get it to work for me....On my Nintex Form I have a button type "save" and named "savebutton" and another button type "javascript"  named "add" and client click is set to "MyFunction() 

I created MyFunction in the Form Settings Custom JavaScript:

function MyFunction()

{

NWF$("savebutton").click();

alert("The savebutton was clicked.");

}

I see the alert, but the " savebutton" button is not clicked and the record is not saved

What am I doing wrong?

Badge

Has anyone found a solution to this problem?

many thx..

Badge +2

In this case the name selector doesn't work properly, try again with a jQuery class selector.

'MyFunction' looks like this:

function MyFunction() {

//css selector: first assign the css class 'mySaveClass' to the save-button

NWF$(".mySaveClass").click();

}

This solution works for me, without any problems

Badge +2

Did you run already the F12 Developer Tools in IE? Open the Developer Tools and type in the console: NWF$(".mySaveClass").click(); --> Please compare with the screenshot!.

F12Tolls.JPG

If nothing helps you could send me your workflow (export and save as * .nwf)

Badge +2

Hi Jim,

ok the save-button was found, then you've probably only mistyped. Please check again the settings in the form.

1.

176567_pastedImage_0.png

2.Control Settings- Button (SAVE)

176568_pastedImage_1.png

3. Control Settings - Button (ADD)

176569_pastedImage_2.png

4. Settings - Form

176570_pastedImage_3.png

My Form is attached. The host list is a simple custom list without any changes.

Badge +2

I'm really pleased.It is often the small things that make the big difference.

Badge

Hi Everyone, I wanted to share what I learned about redirects on Nintex forms. So to redirect on Submit/Save, it's pretty straightforward. You just go to the general form Settings and find the Redirect URL field under the Advanced heading:

203269_pastedImage_1.png

This will take care of the redirect on Submit. However, if you are working with a Nintex approval flexi-task, you also have to consider your Cancel and Reject buttons as well. To redirect on Cancel, you have to use some custom Javascript. To do this, go into general form Settings and add a function in the Custom Javascript field. There are different ways to do this. Two scripts I have successfully used are:

function doRedirect(){

history.go(-1);

}

 

This function will take the user back one page in their browser history, which should return them to the page from which they launched the form. This can get weird, however, if your form is launched in a dialog, so I tend to avoid it. The more specific one is this:

function goHome(){

 window.location.replace("https://portal.geha.com/co/SitePages/home2.aspx");

}

 This one directs the user to a specific location. Enter the URL in quotation marks and parens. And you'll want to use this one especially if your redirect target is on another site.

After entering the script into the form Settings, you then need to configure the Cancel button as follows:

Button action: JavaScript

Button label: Cancel (Or whatever you want. If you don't specify this, it will say "Custom")

Advanced > Client click > doRedirect();       {or goHome(); -- whatever the name of your function is}

203270_pastedImage_3.png

Back to my approval task, I now need to redirect on REJECT as well. You do NOT want to use custom Javascript to redirect on the Reject button. If you do this, the redirect will work, but the 'submit' part will not work and your approval workflow will hang in In Progress status. The workflow will not continue or complete. So you need to make sure that the Reject button is configured to be a Save and Submit action:

203271_pastedImage_4.png

No Javascript. No Client Click setting. This will redirect the user as indicated in the general form Settings and also allow the workflow to continue. 

Hope this helps!

Badge +6

HI

This is all great information.  However, I have the situation whereby when the user clicks on the name of an item (rather than clicking on New and Edit), the Display form appears.  This only displays the Close button and not other buttons that I add onto the form.  How do I access the Nintex Display form?

Thanks again.

Reply