1

I need the Save button on a list's NewForm.aspx page to redirect to a "Thank You" page. I need to do this without creating a custom form or a new page (though I'm willing and able to create one for testing), as a consultant customized the form behavior on the default page using JavaScript (I think), and I have no idea how to get that transferred to a new page or custom form. Further, there are a number of content types we're working with, and creating a custom form seems to be limited to one content type.

The consultant is no longer with us and is unavailable for additional help. I have very little experience with JavaScript and am not at all comfortable with it, though I could probably read and follow the gist of what a script is doing.

The consultant left me with instructions on how to create new buttons within a CEWP, which I am able to do successfully, but I am unable to find a way to hide the default buttons on the ListFormWebPart.

I've read numerous articles saying to specify the Source query string, but I can't find a step-by-step guide on how to do that. There are also numerous JQuery/JavaScript options out there, but again, none of them are step-by-step enough for me to follow along.

TL;DR: How do I edit the Save button on a form to redirect to a Thank You page without creating a custom form?

Edit: I should mention if this is not possible, I may just have to go back to the client and tell them as much. I don't want to throw anyone under the bus, but the consultant knew my technical limitations (I just recently took on this job, and part of her job was to train me) and I could tell the client as much.

  • Open a newform, add a source=http://cnn.com querystring parameter to url, press enter, now save the form, That will show you what it does – Danny '365CSI' Engelman Sep 1 '16 at 20:23
  • I understand what it does, I don't know how to add the querystring parameter "permanently" so to speak so it happens every time an item is added – rolemartyr-x Sep 1 '16 at 20:25
  • 1
    You can control it from an originating link, or change the New Item link with JS, or use HTML5 magic to add it to url on the NewForm – Danny '365CSI' Engelman Sep 1 '16 at 20:30
  • @Danny, thanks for your responses. Because I'm still so new, your last comment was similar to other answers that I still don't quite grasp yet. I was looking for a more step-by-step answer to walk me through. That said, it's good information to have for when I am more comfortable, and I do appreciate you sharing your knowledge – rolemartyr-x Sep 2 '16 at 12:38
  • @Danny'365CSI'Engelman, you are telling use HTML5 magic, to ad it to the url on the newform. can you pls elaborate it , how to do it. any sources .. – prasadwt Oct 21 '18 at 11:46
4
  1. Click add a new item in your list. Now the NewForm.aspx Form opens up.

  2. Edit this page and add a Script Editor or CEWP.

  3. Now use the Presave function (code written under this function executes when the 'save' button is clicked). You can add some code to the script editor or CEWP.

Note: You need to add reference for Jquery in the code, on the top.

See code below for reference:

function PreSaveAction() {    
    var url = "Paste Thank you Page Url here";
    window.location.href = url;    
}
  • Thank you! This worked perfectly. I will say for anyone that might be searching how to do this that I implemented this by adding a CEWP, edited the HTML on it to include <script src="<path to .js file in Site Assets"></script>, then created the JavaScript file in SPD and saved it to Site Assets. This was the most straightforward and easiest method I've found to use so far. – rolemartyr-x Sep 2 '16 at 12:35
  • You are Welcome. Happy to help you :) – mohd tahir Sep 2 '16 at 12:42
  • I noticed when I implemented this that list items are not being created upon clicking Save. Does the above code bypass submitting the information? I can't imagine there would be much use in having someone fill out a form and then not actually collecting the data... – rolemartyr-x Sep 6 '16 at 17:43
1

Yes @rolemartyr-x from a SharePoint developer's view I would say it is useful collecting user's data and using the same data over the Redirect page. But in this case this will suffice your current need:

--> Whenever you will open a new form(for creating a new item) in a SharePoint list, you will find a similar URL in the browser's window :

https://xyz.sharepoint.com/Lists/LIST%20A/NewForm.aspx?Source=https%3A%2F%2Fxyz%2Esharepoint%2Ecom%2FLists%2FLIST%2520A%2FAllItems%2Easpx&RootFolder=

--> We are supposed to change the source URL on this page(in the bold).

For Example:

https://xyz.sharepoint.com/Lists/LIST%20A/NewForm.aspx?Source= Paste Your Redirect Page/Thank you page URL here

--> This will save the item as well. But the catch is you will have to add a link somewhere to the Newform.aspx page of your list, which should be appended with the URl as above. Once the user clicks this link, he/she will be directed on the NewForm.aspx. For example you can add this link on your homepage(on the top navigation). If you need more help let me know!

  • can you tell what needs to be done, if i am having a querystring parameter with newlycreatedID appended in the editform.aspx url, ie, i wanna redirect to editform.aspx?ID=100 , say 100 is the newlycreatedid in my list , and i have this ID fetched, during the presaveaction. – prasadwt Oct 21 '18 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.