Client Script
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 will execute in four ways
On Load: Runs when a form is loaded
On Change: Runs when a particular filed changes value
On Submit: Runs when a form is submitted
On CellEdit: Runs when a cell on a list changes value
Procedure to create client script
1. In the left navigation pane under System Definition we will find the client
script
2.Below is the table where we can find all client scripts.
3.Click on new button to create Client script
4.There are 4 types of client script
onCellEdit
onChange
onLoad
onSubmit
5.Action gets triggerd based on this 4 types of events.
OnLoad
If we select the onLoad then when the page will load, the client script will run.
OnChange
onChange() client script will get executed when user change any value in an
existing form.
OnSubmit
onSubmit() client script will get executed when use submits the form.
onCellEdit
It is used in list view. Cell mean a particular row inside a column. Like a excel
cell.
In list view in service now we will get the value as a tabular form so here one
value is like cell value.So here if we want to modify any value and trigger a
client script then we can use onCellEdit.