Form Submit then redirect to previous URL wherever that is

  • 31 October 2018
  • 5 replies
  • 110 views

Badge +1

I have several pages that have a link to Add a New Item to a List with an Attachment. Let's say Pages A, B, and C. After the new item has been added and they press Submit, I want the user to go back to their previous page, wherever they started from. If they started on Page A, I want them to go back to Page A. If they started on B, return to B, and so on. I do not want to direct every user to Page X because that's not where they started. 

I have searched the 'net and could only find some javascript that reportedly got the previous page url, but then there was no additional help on where or how to use that information. And when I put that code into my page in a Script Editor Web Part, I press OK and my page crashes and will not reload. 

Many links that I have found are outdated and only contain other links that no longer exist. 

We are NOT allowed to use InfoPath.

We are NOT allowed to use SharePoint Designer. 

We are using SharePoint 2013. 

Can anyone please help?

Thank you

Susan


5 replies

Badge +1

Hi Susan

If you look at the url from the "new item" link, it would usually look something like this: http://mynintexdomain/Lists/MRO%20Test%203/NewForm.aspx?Source=http%3A%2F%2Fmynintexdomain%2Fspielwiese%2FLists%2FMRO%2520Test%25203%2FAllItems%2Easpx&RootFolder=

The "Source=xyz" path tells the form where to Redirect after being submitted. if you have the possibility to change these links you have on pages A, B and C to pass the correct "Source" parameters, then you should be fine without the need of any JavaScript within the form. The link on page A would need to have the (url-encoded) url of page A as source parameter (http://blah/NewForm.aspx?Source=http%3A%2F%2Fblah%2FpageA), the link on page B would have the url of page B as source parameter etc.

Martin

Badge +1

Thank you!! I will give this a try. Our office is moving this weekend so it will be early next week when I can give it a try. 

happy.png

Susan

Badge +1

That doesn't quite work. No matter which page I start from, when I get to the new Form page, it has the appropriate Source=blah%20blah%20PageA or ...PageB or ...PageC identification. Why would I need to encode the Source path if SharePoint does that automatically?

There's only one blank for the Redirect URL entry on the Form itself (Form Settings, Advanced). *This* is what has to be different no matter what page the user starts on. I don't want them to hit the back button, I want the form to automatically send them back there after being submitted.

Where do I define "go back to source" when the form is done? I don't just put "source" in the Redirect URL box, or do I?

Thank you!

Susan

Badge +1

Hi Susan

Ok, that's what I did:

  1. Create a List in SharePoint, called "Test Redirect"
  2. Add a Nintex Form (I used a classic form to test) to the list
  3. Click the "new item" link on the list
  4. This shows up the form. The Address bar says https://nintexTest/spielwiese/Lists/Test%20Redirect/NewForm.aspx?Source=https%3A%2F%2FnintexTest%2Fspielwiese%2FLists%2FTest%2520Redirect%2FAllItems%2Easpx&RootFolder= (the list is on the "spielwiese" subsite)
  5. Manually change the url to look like this: https://nintexTest/spielwiese/Lists/Test%20Redirect/NewForm.aspx?Source=/ and hit enter
  6. Fill in the form and submit it
  7. You will be redirected to the SharePoint root

What happened? I replaced the Source query-string by the relative url /. This is the url of the site root. After submitting the form, SharePoint redirects me to this url (as long as it's within SharePoint). Note that I didn't url-encode the parameter to keep it simple, but usually you should.

What does this mean? If you add a "Source" Parameter to the url, SharePoint will bring you there after submitting the form. This is not a Nintex feature, but a SharePoint feature, but in my test it worked also when using a Nintex form.

And now? You can create a link to a form, which also contains the information about where you want to user to be redirected afterwards. Place a link to the form on your Page A, and make sure it has the query string ?Source=/SitePages/PageA.aspx, and it will bring the user back to Page A after submitting the form. Don't enter anything into the "Redirect URL" Field in the form settings, because the redirection will be handled by SharePoint, not by Nintex.

I tested this on Nintex for SharePoint 2016 with classic forms.

I hope this helps

Martin

Badge

The Urls from the "add object" link usually looks like this: https://seotoolsystem.com/htaccess-redirect-generator Lists/MRO%20Test%203/NewForm.aspx?Source=http%3A%2F%2Fmynintexdomain%2Fspielwi...=

The "Supplier" route instructs the form where to redirect to that after receiving a submission. You shouldn't require any Scripting within the form if you have the option to modify the links on sites A, B, and C to send the proper "Source" parameters. The url on webpage A would need to have the (url-encoded) url of page B as source parameter.

Reply