---
sourceDocument: Yokohama API Reference
sourceDocumentLink: https://www.servicenow.com/docs/r/yokohama/api-reference

 Release :

    - yokohama

ft:locale :

    - en-US

ft:publication_title :

    - Yokohama API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Client scripts

# Client scripts {#ariaid-title1}

Release version: Yokohama  
Updated May 18, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 minutes to read
Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) Summarized using AI  
This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.  

## Summary of Client scripts

Client scripts in ServiceNow allow you to run JavaScript on the client side (web browser) to respond to client-based events such as form load, form submission, or field value changes.
They enable dynamic interaction with forms by configuring form fields and values in real time as users interact with the form.
This enhances the user experience by providing responsive, context-aware form behavior.
Show full answer Show less  
Client scripts are designed to optimize form usability, not to enforce data security. To protect sensitive data, you should use Access Control Lists (ACLs) or data policies instead.

## Where Client Scripts Run

* Client scripts apply mainly to forms and search pages, except for onCellEdit() scripts which run during list editing.
* They are not supported on ServiceNow mobile applications.
* To control field values on lists, use ACLs, business rules, data policies, onCellEdit() client scripts, or disable list editing.

## Key Client Script Types and Their Uses

* **onLoad()**: Executes when a form first loads, before user input. Used for setting default values or manipulating form fields.
* **onSubmit()**: Runs when a form is submitted, typically for validation. Can cancel submission by returning false.
* **onChange()**: Triggers when a specific field value changes. Provides parameters like old and new values, and flags for loading or template status.
* **onCellEdit()**: Executes during list cell editing, with parameters for the records and values being edited. Supports callbacks to control script execution flow.

## Important Configuration Fields

* **Name**: Identifies the client script.
* **Table**: Specifies the table the script applies to.
* **UI Type**: Defines where the script runs (Desktop only, Mobile/Service Portal, or All).
* **Field Name**: Used with onChange or onCellEdit scripts to specify the target field.
* **Application**: Indicates the application scope of the script.
* **Active**: Enables or disables the client script.
* **Global and View**: Controls the script's applicability across table views.
* **Description**: Documents script purpose and functionality.
* **Messages**: Defines localized messages accessible by the script for UI display.
* **Script**: Contains the actual JavaScript code executed by the client script.

## Script Isolation and Security

New client scripts run in strict mode by default, disabling direct DOM access and access to jQuery, prototype, and the window object to improve security and stability. You can enable DOM access per script by clearing the "Isolate script" option or disable strict mode globally via system properties.

## Practical Considerations for ServiceNow Customers

* Use client scripts to enhance form interactivity and enforce client-side logic like field visibility, mandatory fields, and dynamic value setting.
* Do not rely on client scripts for data security. Always use ACLs or data policies for protecting sensitive data.
* Choose the appropriate client script type based on the event you want to handle (form load, submit, field change, or list cell edit).
* Configure UI Type carefully to ensure scripts run in the intended user interfaces (desktop, mobile, or portal).
* Be mindful that client scripts do not run on mobile apps, so use alternative methods if mobile behavior is required.  
Client scripts allow the system to run JavaScript on the client (web browser) when
client-based events occur, such as when a form loads, after form submission, or when a field
changes value.
<br />

Use client scripts to configure forms, form fields, and field values while the user is using
the form. Client scripts can:  
* make fields hidden or visible
* make fields read only or writable
* make fields optional or mandatory based on the user's role
* set the value in one field based on the value in other fields
* modify the options in a choice list based on a user's role
* display messages based on a value in a field
{#client-scripts__ul_zp5_n5y_vdb}  
Warning:  
Client scripts are intended to optimize the user experience on a form. Client scripts are not meant to protect unwanted access to data.

To prevent unwanted access to data, ensure that sensitive fields are hidden or read-only through ACLs or data policies.

For more information, see [Access Control List Rules](https://www.servicenow.com/docs/access?context=access-control-rules&version=yokohama&pubname=yokohama-platform-security&ft:locale=en-US) or [Data policy](https://www.servicenow.com/docs/access?context=c_DataPolicy&version=yokohama&pubname=yokohama-platform-administration&ft:locale=en-US).

## Where client scripts run {#client-scripts__section_y1n_4z5_zz}

With the exception of onCellEdit() client scripts, client scripts only apply to forms and search pages. If you create a client script to control field values on a form, you must use one of these other methods to control field values when on a list.

* Create an access control to restrict who can edit field values.
* Create a business rule to validate content.
* Create a data policy to validate content.
* Create an onCellEdit() client script to validate content.
* Disable list editing for the table.
{#client-scripts__ul_nml_51t_d1b}  
Note:  
Client scripts are not supported on ServiceNow mobile applications.

## Client script form {#client-scripts__section_yjd_hvg_zz}

{#client-scripts__table_trz_nvg_zz__entry__2}

| Field | Description |
|-|-|
| Name | Name of the client script. |
| Table | Table to which the client script applies. |
| UI Type | Target user interface to which the client script applies. * Desktop: The script runs only in the desktop Core UI. * Mobile / Service Portal: The script runs only in mobile, portal, or configurable workspace UIs. * All: The script executes across all available UIs. {#client-scripts__ul_b1b_ssm_hjc} |
| Type | onLoad() --- runs when the system first renders the form and before users can enter data. Typically, onLoad() client scripts perform client-side-manipulation of the current form or set default record values. onSubmit() --- runs when a form is submitted. Typically, onSubmit() scripts validate things on the form and ensure that the submission makes sense. An onSubmit() client script can cancel form submission by returning a value of false. onChange() --- runs when a particular field value changes on the form. The onChange() client script must specify these parameters. * control: the DHTML widget whose value changed. Note: control is not accessible in mobile and service portal. * oldValue: the value the widget had when the record was loaded. Note: Old values aren't returned for the HTML field type. * newValue: the value the widget has after the change. * isLoading: identifies whether the change occurs as part of a form load. * isTemplate: identifies whether the change occurs as part of a template load. {#client-scripts__ul_bsg_d2r_n4} onCellEdit() --- runs when the list editor changes a cell value. The onCellEdit() client script must specify these parameters. * sysIDs: an array of the sys_ids for all items being edited. * table: the table of the items being edited. * oldValues: the old values of the cells being edited. * newValue: the new value for the cells being edited. * callback: a callback that continues the execution of any other related cell edit scripts. If true is passed as a parameter, the other scripts are executed or the change is committed if there are no more scripts. If false is passed as a parameter, any further scripts are not executed and the change is not committed. {#client-scripts__ul_qm5_z2r_n4} |
| Field Name | Name of the field to which the script applies. Available only if the script responds to a field value change (onChange or onCellEdit script types). |
| Application | Application where this client script resides. |
| Active | Enables the client script when selected. Unselect this field to disable the client script. |
| Inherited | Indicates whether the client script applies to extended tables. |
| Global | If true, the client script runs on all views of the table. |
| View | Only visible when Global is unselected. Views on which the client script will run. |
| Description | Content describing the functionality and purpose of the client script. |
| Messages | Text string (one per line) available to the client script as localized messages using getmessage('\[message\]'). For additional information, see [Translate a client script message](https://www.servicenow.com/docs/access?context=t_TranslateAClientScriptMessage&version=yokohama&pubname=yokohama-platform-administration&ft:locale=en-US). |
| Script | Contains the client script. |
| Isolate script | New client scripts are run in strict mode, in which direct DOM access is turned off. Access to jQuery, prototype, and the window object are also turned off by default. To enable DOM access on a per-script basis, leave the Isolate script option cleared. To turn off strict mode for all new globally scoped client scripts, set the glide.script.block.client.globals system property to false. |
[ ]

{#client-scripts__table_trz_nvg_zz}
**Related concepts**   

* [Client API reference](https://www.servicenow.com/docs/q5afiHTjy4_Er70vupCs7Q "Use client-side JavaScript APIs to control aspects of how ServiceNow AI Platform is displayed and functions within the web browser. This reference lists available classes and methods along with parameters, descriptions, and examples to help control the end-user experience.")

