Thank you for your feedback.
Form temporarily unavailable. Please try again or contact to submit your comments.

Client scripts

Log in to subscribe to topics and get notified when content changes.

Client scripts

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.

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 script form

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.

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.
  • 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.
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.
Note: onCellEdit() client scripts do not apply to dashboard list widgets.
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.
Script Contains the client script.

Where client scripts run

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 API

The client-side Glide API provides classes and methods that you can use in client scripts.