gsftSubmit backend working

sagarpundir
Tera Contributor

I want to know the backend working of gsftsubmit ? how is it woking at backend ?

3 ACCEPTED SOLUTIONS

Zach Koch
Giga Sage
Giga Sage

Take a look at this thread, it may help you

What is gsftSubmit()'s param?? 

If this information helped resolve your issue, please remember to mark response correct and thumbs up to help future community members on this information, thanks!

View solution in original post

Bhimashankar H
Mega Sage

Hi @sagarpundir ,

 

The gsftSubmit function is a client-side utility in ServiceNow used to submit forms typically triggered by buttons or UI actions.

 

It processes like....

  • Submits the HTML form (<form> element in the DOM) to the server.

  • The form submission sends an HTTP POST request back to server to process.
  • The server then pushes any updates or redirects as per the UI Action definition.

  • Depending on the UI Action’s server script, the server sends back a response.

  • The client either reloads the form with updated data or navigates to another page.

 

It takes three parameters:

null (First Parameter):

This parameter represents the parent HTML element to which the notification will be appended. When set to null, it typically means that the notification will be appended to the global notification container, which is often located at the top of the page.

g_form.getFormElement() (Second Parameter):

g_form.getFormElement() is the out-of-the-box method. It is used to retrieve the DOM (Document Object Model) element of the current form. In the context of a UI action, this is likely being used to specify where the notification should be attached within the form.

UI Action Name (Third Parameter):

The third parameter is the name of the UI action itself. This is used as an identifier for the UI action and is often included in the message or title of the notification to provide context about which action triggered the notification.

 

Hope this helps.

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

View solution in original post

Shashank_Jain
Kilo Sage

@sagarpundir ,

 

gsftSubmit just adds an extra flag (sys_action) to the form submission.
The server checks that flag → finds the correct UI Action → runs its server code.

 

Backend Working (Step by Step)

  1. You click the button

    • Browser runs the UI Action client script → gsftSubmit(null, g_form.getFormElement(), 'close_incident').

  2. Form submission happens

    • gsftSubmit submits the form like a normal POST request.

    • Along with form data, it attaches a hidden parameter:

       
      sys_action = close_incident
  3. Server receives the request

    • ServiceNow’s Form processor sees the request.

    • It checks:

      • Which record? (sys_id)

      • Which action? (sys_action)

  4. Server finds the UI Action

    • In the sys_ui_action table, it looks for a record with:

      • action name = close_incident

      • table = current form’s table

    • That’s how it knows which UI Action server script should run.

  5. Executes the server-side script

    • ServiceNow now runs the Server Script of that UI Action.

    • Example:

       
      current.state = 7; // Closed current.update(); action.setRedirectURL(current);
  6. Response back to client

    • After server script finishes, it sends a response (redirect, reload, or update).

    • Browser reloads the form with new values (e.g., incident now shows as Closed).

 

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain

View solution in original post

4 REPLIES 4

Zach Koch
Giga Sage
Giga Sage

Take a look at this thread, it may help you

What is gsftSubmit()'s param?? 

If this information helped resolve your issue, please remember to mark response correct and thumbs up to help future community members on this information, thanks!

Bhimashankar H
Mega Sage

Hi @sagarpundir ,

 

The gsftSubmit function is a client-side utility in ServiceNow used to submit forms typically triggered by buttons or UI actions.

 

It processes like....

  • Submits the HTML form (<form> element in the DOM) to the server.

  • The form submission sends an HTTP POST request back to server to process.
  • The server then pushes any updates or redirects as per the UI Action definition.

  • Depending on the UI Action’s server script, the server sends back a response.

  • The client either reloads the form with updated data or navigates to another page.

 

It takes three parameters:

null (First Parameter):

This parameter represents the parent HTML element to which the notification will be appended. When set to null, it typically means that the notification will be appended to the global notification container, which is often located at the top of the page.

g_form.getFormElement() (Second Parameter):

g_form.getFormElement() is the out-of-the-box method. It is used to retrieve the DOM (Document Object Model) element of the current form. In the context of a UI action, this is likely being used to specify where the notification should be attached within the form.

UI Action Name (Third Parameter):

The third parameter is the name of the UI action itself. This is used as an identifier for the UI action and is often included in the message or title of the notification to provide context about which action triggered the notification.

 

Hope this helps.

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

where i can find this - > the notification will be appended to the global notification container

Shashank_Jain
Kilo Sage

@sagarpundir ,

 

gsftSubmit just adds an extra flag (sys_action) to the form submission.
The server checks that flag → finds the correct UI Action → runs its server code.

 

Backend Working (Step by Step)

  1. You click the button

    • Browser runs the UI Action client script → gsftSubmit(null, g_form.getFormElement(), 'close_incident').

  2. Form submission happens

    • gsftSubmit submits the form like a normal POST request.

    • Along with form data, it attaches a hidden parameter:

       
      sys_action = close_incident
  3. Server receives the request

    • ServiceNow’s Form processor sees the request.

    • It checks:

      • Which record? (sys_id)

      • Which action? (sys_action)

  4. Server finds the UI Action

    • In the sys_ui_action table, it looks for a record with:

      • action name = close_incident

      • table = current form’s table

    • That’s how it knows which UI Action server script should run.

  5. Executes the server-side script

    • ServiceNow now runs the Server Script of that UI Action.

    • Example:

       
      current.state = 7; // Closed current.update(); action.setRedirectURL(current);
  6. Response back to client

    • After server script finishes, it sends a response (redirect, reload, or update).

    • Browser reloads the form with new values (e.g., incident now shows as Closed).

 

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain