Catalog client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 05:55 AM
I have one Variable in catalog item
Case 1:
If i select Yes
I need to populate the another variable
Case 2:
If I select "No"
Another variable should come.
Can some one please provide me the Catalog client script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 08:26 AM
you can simply use newValue to compare rather than using g_form.getValue
Also if value is yes then you want to auto-populate then you should use g_form.setValue()
try this and use correct variable name
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
if (newValue == "yes") {
g_form.setValue('variableName', 'Your Text');
} else {
g_form.setDisplay('u_removed', true);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 06:38 AM
Agree with @Ankur Bawiskar & @Anurag Tripathi , so just giving you path
Check this OOTB UI policy and you wil get idea.
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]
****************************************************************************************************************