Wednesday, April 24, 2013

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.

 sharepoint 2010 survey thank you page

2. Open the site in SharePoint Designer, Go to "Forms" section. Create a New Form by clicking on "New Item Form"
sharepoint 2010 survey thank you

 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.
sharepoint survey redirect

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"
sharepoint 2010 survey finish redirect

6. Select the Form Actions "Commit" and "Navigate to Page" and click "OK"
sharepoint survey thank you page

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:
sharepoint 2010 survey add thank you page

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:
sharepoint 2010 survey thank you message
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



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

16 comments :

  1. EXCELLENT POST. ITS WORKED WITH FIRST OPTION.

    ReplyDelete
  2. ITS WORKED WITH SECOND OPTION.

    ReplyDelete
  3. I 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 ?

    Thanks

    ReplyDelete
    Replies
    1. "Space" in field names could cause this issue.

      Delete
  4. form submit not checking field validations.plz help me

    ReplyDelete
    Replies
    1. You can use "PreSaveAction" to validate fields.

      Delete
  5. Worked 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?

    ReplyDelete
  6. Please how can you do this in SharePoint designer 2013.thanks

    ReplyDelete
  7. For the second method. How do you edit the page to add the CEWP?

    ReplyDelete
    Replies
    1. Are you not getting "Edit Page" option in Site Settings Menu? If not, Append "?PageView=Shared&ToolPaneView=2" to your EditForm.aspx page.

      Delete
  8. Hi,

    Please how can you do this in SharePoint 2013 or SharePoint online. Thanks

    ReplyDelete
  9. Hi
    I 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?

    ReplyDelete
  10. 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?

    ReplyDelete
  11. i have tried the same thing but for some reason my URL doesnt work,i get an error,

    i am sure why if i put bbc.co.uk it works but not our url

    ReplyDelete
  12. great, worked well. Not with a survey with branching.
    I am testing option 2

    ReplyDelete

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...