Client scripts
Run JavaScript in the browser to react to form and field events in real time.
Client scripts run in the user's browser on a form, letting you validate input, show or hide fields, and react the instant a value changes, without a round-trip to the server. They are the counterpart to server-side business rules: same language (JavaScript), opposite side of the wire.
- The four types
- An onChange script
- Keep them light
- Try it Yourself
Client scripts run in the user's browser on a form, letting you validate input, show or hide fields, and react the instant a value changes, without a round-trip to the server. They are the counterpart to server-side business rules: same language (JavaScript), opposite side of the wire.
The four types
An onChange script
The g_form API is your toolbox: g_form.getValue(), setValue(), setMandatory(), setVisible(), setReadOnly(), addErrorMessage(). Use g_user to check roles on the client.
getReference or GlideRecord on the client, which freezes the form.Keep them light
- Prefer UI policies for simple show/hide/mandatory, no code, faster.
- Always guard
onChangewith theisLoadingcheck. - Move real logic to the server; the client should only shape the form.
▸ Press Run to execute.
Runs in a sandbox in your browser. Mock gs and GlideRecord and sample data are provided.