1

I need to override the redirection functionality of "Finish" button in Survey. I have included Survey.js into my site. The code is:

$(document).ready(function(){


 var publishButton = $("input[id$=onetidSaveItem]");
    // change redirection behavior
   publishButton.removeAttr("onclick");
publishButton.click(function SubmitPage(fAddMore, btn) {
    var surveyListName; 
$.ajax({
    url:_spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists(guid'"+ _spPageContextInfo.pageListId.replace("{","").replace("}","") +"')",

    method: "GET",
    headers: { "Accept": "application/json; odata=verbose" },
    success: function (data) {
       // console.log("List Title :" + data.d.Title);
         surveyListName=data.d.Title;
          btn=publishButton;
fAddMore=false;
        var currentUrl = window.location.href;
        currentUrl = currentUrl.substring(0, currentUrl.lastIndexOf('/')-11);
    var formSubmit  = document.forms.frmSubmit;
    var pageCommand = "Cmd=NewField";

    var formAction  =currentUrl+"_layouts/15/mngfield.aspx?i=1" +
                                "&" + pageCommand + "&" +
                                "List="+_spPageContextInfo.pageListId.replace("{","%7B").replace("}","%7D").split('-').join('%2D');
    if (fAddMore)                      
    {
       // var surveyUrl = currentUrl+"_layouts/15/qstNew.aspx/List/"+_spPageContextInfo.pageListId.replace("{","%7B").replace("}","%7D").split('-').join('%2D');
        formSubmit.action = formAction + "&NextUsing=" +  currentUrl.split(':').join('%3A').split('/').join('%2F')+"%5Flayouts%2F15%2FqstNew%2Easpx%2FList%3D"+_spPageContextInfo.pageListId.replace("{","%7B").replace("}","%7D").split('-').join('%2D');

    }
    else
    {
        //setTimeout(function(){ formSubmit.action = formAction + "&NextUsing=" + currentUrl+"Lists/"+surveyListName+"/preview.aspx"; }, 10000);
        formSubmit.action = formAction + "&NextUsing=" + (currentUrl+"Lists/"+surveyListName+"/preview%2Easpx").split(':').join('%3A').split('/').join('%2F');


    }

Here the redirection works fine in chrome.It should actually redirect to preview page.But in IE , it is navigated to mngfield.aspx.

Also, this redirection works fine in IE sometimes.I am not able to guess this issue.

Anyone please help.

7

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.