client script

soniya patil
Tera Contributor

please give me a some real time scenarios on client script 

6 REPLIES 6

Harish Bainsla
Kilo Patron
Kilo Patron
servicenow #skfacts #servicenowdeveloper #ServiceNow #ITSM #ITIL #ServiceManagement #ServiceDesk #IncidentManagement #ChangeManagement #CMDB #Automation #DigitalTransformation #ServiceNowAdmin #ServiceNowDevelopment #ServiceNowCommunity #ServiceNowTraining #ServiceNowIntegration students can log ...

Samaksh Wani
Giga Sage
Giga Sage

Hello @soniya patil 

 

Client Scripts are of 4 Types :-

 

1. OnLoad()

2. onCellEdit()

3. onChange()

4. onSubmit()

 

Lets Take an example of onLoad() Client Script :-

 

There is a form , contains Assigned To Field. My use case is to set the logged in user into the Assigned To Field.

 

I will use onLoad() client script to do that :-  

 

 

 

function onLoad(){

var user = g_user.userID();
g_form.setValue('assigned_to', user);

}

 

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.

 

Regards,

Samaksh

 

varaprasad123
Kilo Guru

1. OnLoad()

    a. try to hide a field on the form while form is loading.

2. onCellEdit()

   a. this you don't try now, maybe , later 🙂

3. onChange()

  a. How do you show a field / populate field based on the field value change, you can start with Incident form, when       priority is high, you have to make Description field mandatory and also show a field message under it. etc.

4. onSubmit()

   On Submit you can throw a confirmation message on the form, or check for date entered in the past/future etc..

 

also, developer.servicenow.com has some examples that you should try.

Rajesh_Bhise
Tera Guru

Hello @soniya patil  - There main two types of client scripts.

1. Catalog client scripts

2. Form Client script.

 

Form Client scripts work at client side forms of servicenow for different reasons.

1. to validate form fields - OnSubmit

2. To Set parameter on change of particular field- OnChange

3. To log alert on form load - OnLoad

4. To validate list view field change - OncellEdit

 

On catalog items we use, catalog  client scripts to perform above operations hence those called as catalog CS.

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.

 

Thank You,

Rajesh