Client Script setting a checkbox to true is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2022 09:27 AM
Hello all,
I have multiple choice field, with three choices. The following client script does not seem to work. I want to set a checkbox to true depending on the multiple choice selected on the catalog item,
Type is onchange
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'OTC') {
g_form.setValue('otc_lm_cash', 'true');
}
else if (newValue == 'RTR') {
g_form.setValue('rtr_icrecon', 'true'); g_form.setValue('rtr_lm_cash', 'true');
}
else if (newValue == 'PTP') {
g_form.setValue('payment_processing', 'true');
}
}
- Labels:
-
Service Portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2022 09:38 AM
Hi there,
Have you debugged that the Catalog Client Script is triggered at all?
If this is on the Service Portal, make sure the UI Type of the Catalog Client Script is set to "All".
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2022 11:50 AM
I have not use debugging before so not sure how to do this.
Client Script is set to 'All' and I have removed the quotes around true and this still does not work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2022 09:39 AM
Hi,
Quotes is not required while setting checkbox value as true. Plesae use the modified script as below:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'OTC') {
g_form.setValue('otc_lm_cash', true);
}
else if (newValue == 'RTR') {
g_form.setValue('rtr_icrecon', true);
g_form.setValue('rtr_lm_cash', true);
}
else if (newValue == 'PTP') {
g_form.setValue('payment_processing', true);
}
}
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2022 09:40 AM
Also if the above script does not work, can you put a alert to see in which block of code the script is executing or failing.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list