Home > CEWP, Lists > Display A Thank You Page After A Survey Is Filled

Display A Thank You Page After A Survey Is Filled

The survey list did not get much of a facelift since 2007. In fact, it still uses the old list settings interface as opposed to ribbon enabled lists. After the user submits (or completes) the survey, s/he is sent to the default page which is usually the summary results. People have used the source=encoded url parameter in the address to redirect users to a certain url after the survey is completed. So, instead of leaving things at default, you could add that parameter to the url of the NewForm.aspx and may be have this as a link for users to click on instead of the typical Respond To This Survey link (ex. from an e-mail message or even an announcements list). Of course, it is easy to adjust the url and remove the ?source=url(encoded). The other issue is if a survey has page breaks. After the first page is filled, the next page will have a different url: EditForm.aspx and stays so till the survey is finished. These and other reporting issues (you get an extra quasi-question called Content Type in the graphical view!)  may convince you to either seek third party tools or use InfoPath if enabled (or supported) in your farm.
There is a work-around for the additional content type question (using JQuery). Here, I will also use JQuery to display a thank you page after the survey is completed – for the sake of enhanced user experience.
You can add your thank you page as html or aspx or even a web part page. Let’s say we have a nice paragraph praising the user for their input and a link to the home of the current site (with target=_top to break out of the dialog, even if this is not XHTML compliant). You would edit the NewForm if your survey is one page but here we will deal with a survey that has page breaks, so we edit the EditForm.aspx and add a CEWP. Could not edit the source, so linked the .js file (uploaded to a library) from the web part properties.
What do we write in that file? If you inspect the Finish button, you will find it has an OnClick event that posts back after a validation check. We take the id of this button and in our js file we unbind the click event and bind a modified version of it.

Substitute your id and your page url, replace nice quotes with plain text ones (if you are copying). Now you have your custom thank you page. Notice I am using the latest jq library (not a must) and no need to link from the Internet – you can put it in a document library and link it from there.

  1. August 22nd, 2011 at 09:56 | #1

    Thanks for this post – this problem was driving us nuts for days until we found your solution.

    However, in our surveys in SP2007, we have two Finish buttons at the end of the survey and this solution was only appending the newHandler value to the top button. After half an hour of fiddling with the jScript, my colleague realised that we also needed to change the handler on the lower button as well (I’d send you a screengrab of our Survey page with the two Finish buttons, but you don’t have image upload here :-)

    Anyway, here’s the revised jScript my colleague Steve came up with that solves the problem:

    $(document).ready(function(){

    // old handler:
    var oldHandlerTop = function() {
    if (!PreSaveItem()) return false;
    WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(“ctl00$m$g_dc354d99_f48d_4a5a_8917_35f5d9d603e5$ctl00$toolBarTbltop$RightRptControls$ctl01$ctl00$diidIOSaveItem”, “”, true, “”, “”, false, true));
    };
    var oldHandler = function() {
    if (!PreSaveItem()) return false;
    WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(“ctl00$m$g_dc354d99_f48d_4a5a_8917_35f5d9d603e5$ctl00$toolBarTbl$RightRptControls$ctl01$ctl00$diidIOSaveItem”, “”, true, “”, “”, false, true));
    };

    // remove old and add new handler:

    var newHandlerTop = function() {
    if (!PreSaveItem()) return false;
    WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(“ctl00$m$g_dc354d99_f48d_4a5a_8917_35f5d9d603e5$ctl00$toolBarTbltop$RightRptControls$ctl01$ctl00$diidIOSaveItem”, “”, true, “”, “”, false, true));
    window.location.replace(“http://oneintranet.qbe.eo/departments/serviceportal/Pages/thanks.aspx”);
    return true;
    };
    var newHandler = function() {
    if (!PreSaveItem()) return false;
    WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(“ctl00$m$g_dc354d99_f48d_4a5a_8917_35f5d9d603e5$ctl00$toolBarTbl$RightRptControls$ctl01$ctl00$diidIOSaveItem”, “”, true, “”, “”, false, true));
    window.location.replace(“http://oneintranet.qbe.eo/departments/serviceportal/Pages/thanks.aspx”);
    return true;
    };

    $(“#ctl00_m_g_dc354d99_f48d_4a5a_8917_35f5d9d603e5_ctl00_toolBarTbltop_RightRptControls_ctl01_ctl00_diidIOSaveItem”).unbind(‘click’, oldHandlerTop).click(newHandlerTop);
    $(“#ctl00_m_g_dc354d99_f48d_4a5a_8917_35f5d9d603e5_ctl00_toolBarTbl_RightRptControls_ctl01_ctl00_diidIOSaveItem”).unbind(‘click’, oldHandler).click(newHandler);
    });

    I’ve left our local IDs in place so you can see the two Finish buttons have slightly different IDs.

    Hope this helps someone who’s having the same problems we were …

    Alan (QBE Insurance)

  2. Abed Khooli
    September 3rd, 2011 at 08:36 | #2

    @Alan McKenzie
    This is true. In NewForm, you have two Finish buttons and their IDs differ slightly. You need to unbind and rebind both.
    Notice that there is also an easier way to do this bu editing the form in SharePoint Designer by replacing the Finish button with an action button that both commits and navigates to a URL.
    AK

  3. Jess
    October 28th, 2011 at 17:17 | #3

    When using the above technique, it does redirect the user but the problem is, even after clicking Finish, the survey is still marked as Incomplete. With a survey marked Incomplete, you won’t have a way to view it… even as the creater of the survey…

  1. No trackbacks yet.
List Of All Lists In A Web Using ListOfLists DataSourceMode