Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

gsft submit()

Harish KM
Kilo Patron
Kilo Patron

Hi ServiceNow techies,

 

                                        Can u please explain me what is gsft submit() function and it's purpose??

 

 

Thanks & Regards

HARISH

Regards
Harish
1 ACCEPTED SOLUTION

sebastian_g_snc
ServiceNow Employee
ServiceNow Employee

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.


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



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.


Please also have a look at Mark Stanger's explanation:


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


View solution in original post

7 REPLIES 7

I know this post is quite old, but in case anyone else is also wondering:

For List type UI Actions, you can use GlideList2.action(action_id, action_name, sys_ids) instead of gsftSubmit().  gsftSubmit() will not work from the List view because g_form is not defined.  The required inputs for GlideList2.action() are the sys_id of the action, the action name, and the sys_ids of records to run the action on (comma-separated string, either the "gsft_allow" attribute from the UI action's DOM element, or the GlideList2.getChecked() items if the gsft_allow attribute is empty).  Here's an example:

function onClickFunction() {
  // Do client-side things, like a confirmation popup

  // After client-side things are done
  var action_id = // sys_id of the UI Action
  var action_name = // action_name of the UI Action
  var tablename = // name of the table for this list

  // Get the GlideList for this table by its tablename
  var the_list = GlideList2.get(tablename);

  // Get the checked values which this action is allowed for
  // First try checking gsft_allow, fall back on GlideList2.getChecked()
  var selected = gel(action_id).getAttribute("gsft_allow");
  if (selected === null || selected === "") {
    selected = the_list.getChecked(); 
    if (selected === null || selected === "") {
      return; // Couldn't find any selected values
    }
  }
  
  // Re-run the action on the server side
  the_list.action(action_id, action_name, selected);
}

if (typeof window == 'undefined')
	serverScript();

function serverScript() {
  // Do server-side things
}

Hopefully this helps someone else.  It took me quite a bit of digging to figure this all out.

Nice Collection Shubham ! Keep Posting these are really nice question for interview preperation .

gsftSubmit(null, g_form.getFormElement(), 'sn_change_cab_notify_all_attendees')

 

Ui action mentioned in 3rd parameter, not aleto find it in list of UI action