onchange client script scenarios

jankirania
Kilo Contributor
 
3 REPLIES 3

Swapna Abburi
Mega Sage
Mega Sage

On change client scripts get executed when a field/variable value changes.

Few simple scenarios:

1. When assignment group is empty or changed, clear assigned to field. - for this scenario, you would be writing on change client script on assignment group field.

 

2. When priority is changed to P1, display an alert/popup message that warm transfer is required. - in this scenario, you would be writing an on change client script on priority field.

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @jankirania 

 

There are many use case for same:

https://developer.servicenow.com/dev.do#!/learn/courses/yokohama/app_store_learnv2_scripting_yokoham...

https://youtu.be/8g3IZIR_U-A

 

https://www.servicenow.com/community/developer-articles/client-script-in-servicenow-with-some-use-ca...

 

https://www.servicenow.com/community/developer-forum/want-some-use-cases-for-client-script-business-...

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************
csa #ServiceNow #TechnoFuncational Disclaimer: These videos are from my training batch. These videos did not promote any ServiceNow Sales pitch or marketing. These videos are only for knowledge purposes & basic on my experience & Knowledge. Redistribution or copying of functionality is not ...

Sandeep Rajput
Tera Patron
Tera Patron

@jankirania Here are some use cases.

 

1. You have a "Category" field and a "Subcategory" field. When the user selects a "Category," the "Subcategory" options should be filtered to show only relevant choices.

2.You need to validate the format of a user-entered value, such as an email address, phone number, or serial number.

3. You want to show or hide fields or sections based on the value of another field.

4. When a specific field is changed, you want to automatically set the value of another field.

5. When a reference field is changed, you want to populate other fields with data from the referenced record.

6. You want to prevent a user from entering certain values in a field.