The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Client Script - Save form before Redirect

Daryll Conway
Giga Guru

I have set-up a redirect from an on-submit client script but I need to save the form before I redirect, currently this just hangs.

Here is my client script...

function onSubmit() {

      if(g_form.getValue("assignment_group") == "a4429af10a0a3c2800b1bc67f7b415c0" && (g_form.getValue("incident_state") == 6 || g_form.getValue("incident_state") == 7)){

              gsftSubmit(null, g_form.getFormElement(), 'sysverb_update_and_stay');

              var URL = "<my_url>.do?uri=u_sys_eng_questionnaire.do";

              alert("You are being redirected to the Systems Support Questionnaire");

              top.window.location = URL;

      }

Can anyone suggest why this hangs and/or a better way to do this?

1 ACCEPTED SOLUTION

Talking about the UI action made me think why don;t I do this in the UI Action rather than a client script so I've done this ...



if(current.assignment_group != "a4429af10a0a3c2800b1bc67f7b415c0" && (current.incident_state != 6 || current.incident_state != 7)){


      action.setRedirectURL(current);


      current.update();


}


else{


      var URL = "https://enxdev.service-now.com/nav_to.do?uri=u_sys_eng_questionaire.do";


      action.setRedirectURL(URL);


      current.update();


}



Which works however it loads like this ...



find_real_file.png



How can I get this to load just as the page I want and not with the banner and side bar duplicated?


View solution in original post

12 REPLIES 12

Just for confirming the problem, can you comment the above redirect line in the UI action ?


I've commented out the redirect in the ui action. I get my alert but it still hangs


Talking about the UI action made me think why don;t I do this in the UI Action rather than a client script so I've done this ...



if(current.assignment_group != "a4429af10a0a3c2800b1bc67f7b415c0" && (current.incident_state != 6 || current.incident_state != 7)){


      action.setRedirectURL(current);


      current.update();


}


else{


      var URL = "https://enxdev.service-now.com/nav_to.do?uri=u_sys_eng_questionaire.do";


      action.setRedirectURL(URL);


      current.update();


}



Which works however it loads like this ...



find_real_file.png



How can I get this to load just as the page I want and not with the banner and side bar duplicated?


Worked it out...



action.setRedirectURL("u_sys_eng_questionaire.do");


Anurag Tripathi
Mega Patron
Mega Patron

replace


gsftSubmit(null, g_form.getFormElement(), 'sysverb_update_and_stay');




with




g_form.save();


-Anurag