This article is a supplement to the ServiceNow documentation. For full documentation please refer ServiceNow official website
Checkout our NEW Video Channel you can like and subscribe too!

Introduction

Client script runs on client side (Browser).We can write simple Java script to meet our client side requirements.

cs1.PNG cs2.PNG

Client Script will execute in four ways

  • On CellEdit: Runs when a cell on a list changes value
  • 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

Procedure to create client script

  1. In the left navigation pane under System Definition we will find the client script cs3.PNG
  2. Below is the table where we can find all client scripts. cs4.PNG
  3. Click on new button to create Client script cs5.PNG cs6.PNG
  4. There are 4 types of client script
    • onCellEdit
    • onChange
    • onLoad
    • onSubmit
  5. Action gets triggerd based on this 4 types of events. cs7.PNG

OnLoad

If we select the onLoad then when the page will load, the client script will run. cs8.PNG

OnChange

cs9.PNG

OnSubmit

cs10.PNG

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.

Example:

In the problem table we have Configuration Item Filed. Here when we select any CI in the field then automatically support group of the CI is populated in the assignment group in the problem table. cs11.PNG

For that we need onchange Client script as when we select the CI name then only assignment group is filled with CI support group. So we need to create a onchange client script

If We want to create a client script of problem table then

Right click on the form of

problem table> configure> client script

cs12.PNG

Click new button to create a client script cs13.PNG cs14.PNG

    Content