Changing the "Save" button behavior

georgimavrodiev
Mega Guru

Hello,

Happy New 2017!


I would like to ask if there is a way via which the "Save" button behavior can be changed in ServiceNow.

Let me describe my request:

I am using Helsinki, Patch 7.
If I use the "Save" button on a page — the task gets processed and the system "brings" me to the top of the page, not the place on which I was before clicking on the "Save" button.
My goal is to "stay" on the same place in the page when the saving task is processed and completed.
Is this possible to be achieved somehow?

Thank you in advance!


Best Regards,
Georgi Mavrodiev

1 ACCEPTED SOLUTION

anurag92
Kilo Sage

Save button actually performs a Server operation and redirects to the same page.



Only option I can think of for your purpose is to define a Client UI action, which performs a GlideAJAX call to a script include in order to save all the values of the form to Server. This will also prevent load of the page simply.



I created a Custom Save button with below code on RITM:



function customSave() {


  var num = g_form.getValue('number');


  var cust = new GlideAjax('SIName');


  cust.addParam('sysparm_name','SIFunction');


  cust.addParam('sysparm_item',num);


  cust.getXMLWait();


// add your code to pass values using g_form.getValue and the addParam


  var answer = cust.getAnswer();


}



On Script include side, I created a table object by glide, got the record using number parameter, got the other passed values from the form using this.getParameter() and performed an update. This prevents the form load.



Let me know if this serves your purpose.


View solution in original post

2 REPLIES 2

anurag92
Kilo Sage

Save button actually performs a Server operation and redirects to the same page.



Only option I can think of for your purpose is to define a Client UI action, which performs a GlideAJAX call to a script include in order to save all the values of the form to Server. This will also prevent load of the page simply.



I created a Custom Save button with below code on RITM:



function customSave() {


  var num = g_form.getValue('number');


  var cust = new GlideAjax('SIName');


  cust.addParam('sysparm_name','SIFunction');


  cust.addParam('sysparm_item',num);


  cust.getXMLWait();


// add your code to pass values using g_form.getValue and the addParam


  var answer = cust.getAnswer();


}



On Script include side, I created a table object by glide, got the record using number parameter, got the other passed values from the form using this.getParameter() and performed an update. This prevents the form load.



Let me know if this serves your purpose.


Hello Anurag,






Thank you very much for your reply!


I am marking it as "Correct Answer".




Have a wonderful day ahead, Anurag!




Best Regards,
Georgi Mavrodiev



IT Consultant
Do IT Wise




You can visit us in our Web Site: http://www.doitwise.com