what is the Use of gsftSubmit , why should we use it, when use it?

chanikya
Tera Guru

Hi,

Please don't copy and past WIKI information, please explain in your own words..

 

why should we use, ?? when ??? why??? what is the purpose 

i have taken this script from wiki.. what is explains here , : UI action: Reopen Incident

already we have UI action name ,so whay should we use gsftSubmit ????

function reopen(){
   if(g_form.getValue('comments') == ''){
      //Remove any existing field message, set comments mandatory, and show a new field message
      g_form.hideFieldMsg('comments');
      g_form.setMandatory('comments', true);
      g_form.showFieldMsg('comments','Comments are mandatory when reopening an Incident.','error');
      return false;  //Abort submission
   }
   //Call the UI Action and skip the 'onclick' function
   gsftSubmit(null, g_form.getFormElement(), 'reopen_incident'); //MUST call the 'Action name' set in this UI Action
}

//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if(typeof window == 'undefined')
   serverReopen();

function serverReopen(){
   //Set the 'State' to 'Active', update and reload the record
   current.state = 2;
   current.update();
   gs.addInfoMessage('Incident ' + current.number + ' reopened.');
   action.setRedirectURL(current);
}

11 REPLIES 11

Dhruv Gupta1
Kilo Sage
Kilo Sage

 

It is mostly used in UI actions that have a client side and a server side script.

gsftSubmit(null, g_form.getFormElement(), "ui action id") triggers the UI Action which is specified in the 3rd parameter, which is the action name/element id.

 At the end of the client side script, you call gsftSubmit in order to trigger the UI Action again - this time running only the server side code.

Hi,

 

i didn't understand it properly, already we have UI Action name and Button in incident table right??

 

then what is the purpose of this using .....

Just check this link it will resolve your query

 

https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/

Jaspal Singh
Mega Patron
Mega Patron

Hi Chanikya,

 

gsftSubmit is used to execute the Server-side section of the script after the client-side portion has been completed successfully.

 

For eg. in your case till the time

 

      g_form.hideFieldMsg('comments');
      g_form.setMandatory('comments', true);
      g_form.showFieldMsg('comments','Comments are mandatory when reopening an Incident.','error');
 

validation is not successful at the Client side, Server-side function would not be initiated.

 

Passing Action name as parameter in gsftSubmit ensures the Client side validation to move ahead.

 

Hope this gives clear understanding.

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.