client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2023 07:55 AM
please give me a some real time scenarios on client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2023 08:10 AM
Hi please check below links
https://www.servicenowelite.com/blog/2014/2/19/client-scripts-examples
https://www.basicoservicenowlearning.in/2019/12/client-script-in-servicenow.html
https://youtu.be/wM128lO6cbY?si=GRWvac7HJHGqFEDs
if you get answer please accept solution and mark helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2023 11:02 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2023 07:15 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2023 09:00 PM
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