SharePoint Survey - Redirect to Thank You Page on Finish
Requirement is to redirect users to Thank You Page in SharePoint Survey on clicking Finish button.
One quick trick comes to my mind is: Appending Source parameter to the Survey's NewForm URL.
E.g.
http://sharepoint.crescent.com/Lists/TownhallMeetingSurvey/NewForm.aspx?source=/SitePages/thankyou.aspx
Not a bad idea, But the problem is: It doesn't matter whether you click on "Finish" or Cancel button, You will be redirected to "Thank You" page! Also, it won't work when you have Branching enabled in SharePoint Survey!
How to Create a Thank You page for SharePoint 2010 Survey:
Lets overcome the above issue with SharePoint designer.
1. Create a new Web Part page (not Wiki page!) and place some descriptive content and/or images in it. I've made the below page. Named it as "thankyou.aspx" under SitePages.
2. Open the site in SharePoint Designer, Go to "Forms" section. Create a New Form by clicking on "New Item Form"

3. Give it a Name, Choose form type as "New Item Form" and enable "Set as default form for the selected type" and click on "Ok" to create the new form.

4. Edit the New form we've just created. Open the "New.aspx" page in SharePoint Designer. Go to Design view and delete all two "Finish" buttons.
5. Insert SharePoint Form Action button from "Insert Menu >> SharePoint >> Form Action Button"

6. Select the Form Actions "Commit" and "Navigate to Page" and click "OK"
7. Click on the "Form Action" input button and go to code view. Update the code for input button as:
8. Save and close the page. That's all!
See the SharePoint 2010 survey thank you page in action:

Another method to add thank you page in SharePoint 2010 survey:
If you don't want to use SharePoint designer method as illustrated above, There is an another way. Create an additional question at the end in the survey, as "Thank You for participating in Survey! Click on Finish to complete." of "Single Line of Text". Add page separator just before this last question. Go to the Survey, Navigate to the last question and Edit the page. Insert a CEWP, place the below code in it.
Here is my another post on sending users to Thank you page from SharePoint list forms:
Redirect Users to Thank You page from NewForm.aspx in SharePoint
Update: Use this Script in a Script Editor Web part for SharePoint 2013/2016:
One quick trick comes to my mind is: Appending Source parameter to the Survey's NewForm URL.
E.g.
http://sharepoint.crescent.com/Lists/TownhallMeetingSurvey/NewForm.aspx?source=/SitePages/thankyou.aspx
Not a bad idea, But the problem is: It doesn't matter whether you click on "Finish" or Cancel button, You will be redirected to "Thank You" page! Also, it won't work when you have Branching enabled in SharePoint Survey!
How to Create a Thank You page for SharePoint 2010 Survey:
Lets overcome the above issue with SharePoint designer.
1. Create a new Web Part page (not Wiki page!) and place some descriptive content and/or images in it. I've made the below page. Named it as "thankyou.aspx" under SitePages.
2. Open the site in SharePoint Designer, Go to "Forms" section. Create a New Form by clicking on "New Item Form"

3. Give it a Name, Choose form type as "New Item Form" and enable "Set as default form for the selected type" and click on "Ok" to create the new form.

4. Edit the New form we've just created. Open the "New.aspx" page in SharePoint Designer. Go to Design view and delete all two "Finish" buttons.
5. Insert SharePoint Form Action button from "Insert Menu >> SharePoint >> Form Action Button"

6. Select the Form Actions "Commit" and "Navigate to Page" and click "OK"

7. Click on the "Form Action" input button and go to code view. Update the code for input button as:
<input type="button" value="Finish" name="btnFormAction" onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={/sites/marketing/SitePages/thankyou.aspx}')}" style="width: 119px" />
8. Save and close the page. That's all!
See the SharePoint 2010 survey thank you page in action:

Another method to add thank you page in SharePoint 2010 survey:
If you don't want to use SharePoint designer method as illustrated above, There is an another way. Create an additional question at the end in the survey, as "Thank You for participating in Survey! Click on Finish to complete." of "Single Line of Text". Add page separator just before this last question. Go to the Survey, Navigate to the last question and Edit the page. Insert a CEWP, place the below code in it.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> //Or place the jquery.js file in 14 hive and refer it <script type="text/javascript"> $(document).ready(function() { //Hide the Text field for Thank you Question $("input[title$='Thank You for participating in Survey! Click on Finish to complete.']").parent('span').parent('td').parent('tr').hide(); }); </script>This code will hide the single line of text input field and give thank you message. See the above code in action:
Here is my another post on sending users to Thank you page from SharePoint list forms:
Redirect Users to Thank You page from NewForm.aspx in SharePoint
Update: Use this Script in a Script Editor Web part for SharePoint 2013/2016:
<script type="text/javascript" language="javascript"> function changeRedirect(options) { for (var i = 0, buttons = document.querySelectorAll(options.selector); i < buttons.length; i++) { var newOnClick = function(originalOnClick) { return function(){ Nav.navigate = STSNavigate = function() { window.location = options.redirectTo } originalOnClick() } } buttons[i].onclick = newOnClick(buttons[i].onclick) } } document.addEventListener("DOMContentLoaded", function(event) { changeRedirect({ selector: "input[value=Save]", redirectTo: "https://yoursite.com/pages/thankyou.com" }) changeRedirect({ selector: "input[value=Cancel]", redirectTo: "https://yoursite.com/" }) }) </script>
EXCELLENT POST. ITS WORKED WITH FIRST OPTION.
ReplyDeleteITS WORKED WITH SECOND OPTION.
ReplyDeleteI did the first option (and controlled twice) but i got "The data source control failed to execute the insert command" when clicking on "Finish". Any idea ?
ReplyDeleteThanks
"Space" in field names could cause this issue.
Deleteform submit not checking field validations.plz help me
ReplyDeleteYou can use "PreSaveAction" to validate fields.
DeleteWorked with first option except switching to code view I simply added the URL in the settings option of "Navigate to page." However, after doing so makes my cancel/go back button not work at all. Any suggestions?
ReplyDeletePlease how can you do this in SharePoint designer 2013.thanks
ReplyDeleteFor the second method. How do you edit the page to add the CEWP?
ReplyDeleteAre you not getting "Edit Page" option in Site Settings Menu? If not, Append "?PageView=Shared&ToolPaneView=2" to your EditForm.aspx page.
DeleteHi,
ReplyDeletePlease how can you do this in SharePoint 2013 or SharePoint online. Thanks
Hi
ReplyDeleteI am using SharePoint 2013 and I cannot insert the form action control. It won't let me drop any dataview control in the code anywhere. Can you help me out?
I am using SharePoint 2010 and SharePoint 2010 Designer and when I created my custom form, I lost all of my branching. How can I re-establish the branching I need on my survey?
ReplyDeleteSame here
Deletei have tried the same thing but for some reason my URL doesnt work,i get an error,
ReplyDeletei am sure why if i put bbc.co.uk it works but not our url
great, worked well. Not with a survey with branching.
ReplyDeleteI am testing option 2
I am using this in Office 365:
ReplyDeletefunction changeRedirect(options) {
for (var i = 0, buttons = document.querySelectorAll(options.selector); i < buttons.length; i++) {
var newOnClick = function(originalOnClick) {
return function(){
Nav.navigate = STSNavigate = function() {
window.location = options.redirectTo
}
originalOnClick()
}
}
buttons[i].onclick = newOnClick(buttons[i].onclick)
}
}
document.addEventListener("DOMContentLoaded", function(event) {
changeRedirect({
selector: "input[value=Finish]",
redirectTo: "https://myteams.toyota.com/sites/tmnaisa/OCIO/CTI/CommSecure/SitePages/thankyou.aspx"
})
changeRedirect({
selector: "input[value=Cancel]",
redirectTo: "https://myteams.toyota.com/sites/tmnaisa/OCIO/CTI/CommSecure/SitePages/thankyou.aspx"
})
})
unfortunately, I got error page after click "Finish", what is the problem?
ReplyDeleteIn 2013 the redirect works perfectly - unfortunately the survey does not get marked as complete.
ReplyDeleteGah! I missed the new code for 2013/2016. It looks like there's something malformed in changeRedirect parts b/c it's being ignored. (And it makes JSLint very angry)
ReplyDeleteUnfortunately I cannot figure out how to paste code into the comments here...
Hi, redirection is not working for my 2010 SS designer option two... I was hoping to use it. Any suggestions?
ReplyDelete