Supported client script types and APIs
Summarize
Summary of Supported client script types and APIs
This document outlines which client scripts and APIs are supported in the ServiceNow Service Portal environment as of the Yokohama release. Understanding these limitations and capabilities helps ServiceNow customers effectively implement client-side scripting that works reliably within Service Portal, ensuring compatibility and optimal user experience.
Show less
Supported Client Script Types in Service Portal
- Catalog Client Scripts: Must have the UI Type set to All or Mobile / Service Portal. Scripts marked as Desktop are unsupported because they use legacy APIs not available in Service Portal.
- Validation Scripts: Require the UI Type to be All or Mobile / Service Portal. In new instances, various validation scripts are active by default. For upgraded instances, the Mobile and Service Portal versions must be manually activated to validate user input within the portal. UI scripts can be called from validation scripts using the
guiscriptsglobal object, provided the UI script’s Global field is false and UI Type is set appropriately. - UI Scripts: Must be set to UI Type All or Mobile / Service Portal. Desktop UI scripts are unsupported due to reliance on legacy APIs.
- UI Actions: All server-side UI Actions are supported; however,
setRedirectURL()calls are ignored because redirection is handled differently in Service Portal. UI Actions marked as Client are ignored in forms within Service Portal. - UI Policies: Supported, but declarative UI Policies are recommended. Avoid scripting unless necessary for complex conditions.
- UI Macros and Formatters: Not supported, as they rely on Jelly, which is incompatible with Service Portal.
Supported Client-Side APIs
Service Portal supports a subset of client-side APIs usable in onLoad, onChange, and onSubmit scripts. These APIs enable interactions with form fields, messages, and related lists.
- gform: A comprehensive API to manipulate form fields (e.g., get/set values, show/hide fields and messages, manage options, validate input). Note that using
variables.varnamenotation and globalgformin widget client controllers or UI scripts is unsupported. - glist: Supports list operations like adding/removing items, resetting, and setting queries.
- gservicecatalog: Provides a method to check if the current form is an order guide.
- GlideAjax: Facilitates asynchronous server calls for data retrieval. Synchronous calls like
getXMLWait()are not supported in Service Portal; asynchronous methods must be used instead. GlideAjax cannot be used within widget client controllers. - GlideRecord: Enables querying and manipulating records with asynchronous support.
- i18NV3: Supports internationalization by retrieving localized messages asynchronously.
Practical Implications for ServiceNow Customers
When developing or migrating client scripts to Service Portal, always set the UI Type to All or Mobile / Service Portal and verify that only supported client-side APIs are used. Avoid legacy Desktop scripts and synchronous GlideAjax calls. Use declarative UI Policies whenever possible to reduce scripting complexity. Be aware that some platform features like UI Macros and Formatters are unavailable, so plan alternative implementations accordingly.
Some client scripts are not supported in Service Portal. Others must have a UI type set to All or Mobile / Service Portal. If using a client script in the Service Portal, only client-side APIs supported in a mobile environment can be used.
Client script support in Service Portal
| Client script | Description |
|---|---|
| Catalog client scripts | Service Portal requires that the UI Type field be set to All or Mobile / Service Portal. Client Scripts marked as Desktop rely on legacy APIs that are not supported in Service Portal. Before flagging a script as Mobile / Service Portal or All, make sure you are only using supported client-side APIs. |
| Validation scripts | Service Portal requires that the UI Type field be set to All or Mobile / Service Portal. Client Scripts marked as Desktop rely on legacy APIs that are not supported in Service Portal. Before flagging a script as Mobile / Service Portal or All, make sure you are only using supported client-side APIs. Validate user input in a specific field type using a validation script. In new instances, Service Portal includes XML, Script, Script (Plain), Email, and Version validation scripts by default. If upgrading from a previous release, the Mobile and Service Portal version is not active by default. You must activate the Mobile and Service Portal version of the validation script to validate user input in the Service Portal. See Activate Service Portal validation scripts. Note: To call a UI script within a Validation script, use the g_ui_scripts
global object. For more information, see GlideUIScripts.
Verify that the UI script has the Global field set to
false and UI Type set to Mobile / Service Portal or All. |
| UI scripts | Service Portal requires that the UI Type field be set to All or Mobile / Service Portal. Client Scripts marked as Desktop rely on legacy APIs that are not supported in Service Portal. Before flagging a script as Mobile / Service Portal or All, make sure you are only using supported client-side APIs. |
| UI Actions | All server-side UI actions are supported in Service Portal, although setRedirectURL() operations are ignored because Service Portal forms handle redirection in a different way than the platform. The form widget ignores any UI Actions marked as Client. |
| UI Policies | Supported, although you should use only declarative UI Policies. Avoid scripting unless the outcome cannot be achieved through the condition builder. |
| UI Macros | Not supported as UI macros use Jelly. |
| Formatters | Not supported as formatters use Jelly. |
Supported client-side APIs
Supported client scripting APIs for use in onLoad, onChange, and onSubmit client scripts.
For detailed class and method information, see the Client API reference.
| Class | Available methods |
|---|---|
| g_form |
Note: Using the variables.var_name notation with the g_form API
is not supported in Service Portal. g_form as a
global object cannot be used in a widget client controller or in a UI script. |
| g_list |
|
| g_service_catalog | isOrderGuide() |
| GlideAjax |
Note:
|
| GlideRecord |
|
| i18NV3 | getMessage(String messageKey, Function callback) |