top of page

Experiencing challenges with ServiceNow support?

IKC provides professional, reliable assistance that covers gaps not supported by ServiceNow

and without the high costs of traditional services.

 

Starting from just $1,000

Decoding gsftSubmit() in ServiceNow




Are you working with UI Actions in ServiceNow and scratching your head over the gsftSubmit() function? This powerful but often misunderstood function lets you trigger server-side UI Action logic from the client-side. Specifically, its parameters can be a bit confusing. This article will break down the gsftSubmit() function and its parameters, providing you with a clear understanding of how to use it effectively within your ServiceNow implementations. If you're aiming to enhance user experience and streamline processes through UI Actions, understanding gsftSubmit() is crucial.


Understanding gsftSubmit() and its Parameters


The gsftSubmit() function is a critical part of the ServiceNow client-side scripting arsenal. It allows you to execute a UI Action's server-side logic directly from the client-side, typically in response to a user interaction. This allows for more complex processing and interaction with the database without a full page reload. The general syntax is:

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

Let’s dissect each parameter


  • First Parameter (Parent HTML Element - usually null): This parameter specifies the HTML element to which a notification related to the UI Action will be appended. When set to null, the notification typically appears in the global notification area at the top of the ServiceNow page. Think of it as defining where a confirmation message or error will display after the UI Action is triggered. Using null is a common and generally recommended approach for most scenarios.


  • Second Parameter (Form Element - g_form.getFormElement()): This parameter leverages the built-in g_form.getFormElement() method. This method retrieves the DOM (Document Object Model) element of the current form. By passing this as the second parameter, you're essentially telling ServiceNow to associate the UI Action's processing with the specific form the user is currently interacting with. This can be useful if you want to target notifications or UI updates to the specific form element instead of the global notification area.


  • Third Parameter (UI Action Name - 'UI_Action_Name'): This is the most straightforward parameter. It's simply the name of the UI Action you want to execute on the server. ServiceNow uses this name as an identifier to locate and run the associated server-side script. Make sure this name exactly matches the "Action name" field in the UI Action definition.


Practical Example


Imagine a scenario where you want to create a UI Action that closes a problem record and displays a confirmation message to the user. The UI Action's client-side onClick() function might look like this:


function onClick() {
  if (g_form.getValue('close_notes') == '') {
    g_form.addErrorMessage('Please provide close notes before closing the problem.');
    return false; // Prevent submission
  }
  gsftSubmit(null, g_form.getFormElement(), 'close_problem'); // 'close_problem' is the UI Action name
}

In this example, before calling gsftSubmit(), the script validates if the 'close_notes' field is populated. If the validation passes, the script calls the server-side logic of the UI Action named close_problem which handles the closing process. A notification, if any, will appear at the top of the page (null for the first parameter), associated with the current form (g_form.getFormElement()).


Alternative Solutions & Considerations


While gsftSubmit() is commonly used, consider these alternatives and points:


  • GlideAjax: For more complex client-server communication, explore GlideAjax. It offers greater flexibility in passing data and handling responses, especially when needing to interact with script includes or custom server-side logic.


  • UI Scripts: If you find yourself repeating the same client-side logic across multiple UI Actions, consider encapsulating it in a UI Script. This promotes code reusability and maintainability.


  • Asynchronous Processing: For long-running server-side operations, consider using asynchronous processing techniques to avoid blocking the user interface.


Mastering gsftSubmit() for Effective ServiceNow Development


Understanding the parameters of the gsftSubmit() function is essential for developing robust and user-friendly ServiceNow applications. By correctly utilizing these parameters, you can control how UI Actions interact with the server, provide meaningful feedback to users, and create a seamless experience within the platform. Take the time to experiment with gsftSubmit() in your development environment, and you'll soon be leveraging its power to build sophisticated ServiceNow solutions.

Experiencing challenges with ServiceNow support?

IKC provides professional, reliable assistance that covers gaps not supported by ServiceNow

and without the high costs of traditional services.

 

Starting from just $1,000

CONTACT

New Zealand HQ

Integrated Knowledge Consulting Office

Level 3, 93 Grafton Road

Auckland

South Korea

Integrated Knowledge Consulting Office

BMY역삼타워 6층

서울특별시 강남구 역삼동 678-10번지

 

info@ikconsulting.com

Thanks for submitting!

  • LinkedIn Social Icon

© Copyright 2025 Integrated Knowledge Consulting. All rights reserved.

bottom of page