Check boxes set as true based on question choices.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 10:13 PM
Hi,
Now I am working catalog item, In catalog having 20+ check boxes .Based on question choices I need auto check(true) the check boxes.
For this I wrote client script. But when I am selected question choice the only one check boxes. its first check box.As for attachement
But I wrote client scripts for 2 nd 3rd check boxes.
I need get auto check the based on script condition .
Can you refer attachments for reference
Can you please help me on that.
Thank you.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 10:21 PM
Hi Siva
are the back-end names of your 2,3rd checkboxes correct in your client script?
Can you share the details of your checkboxe names.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 10:28 PM
Hi Rohila,
Thank you for response,
Yes the back end names correct. Below onces are back end values of question.
field_sales_sales_rep
field_sales_inside_support
field_sales_administration.
Those 3 are back end values of question I need check (true) based question choice
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 10:32 PM
Yes you need to below code in your onchange client script
keep infomessage inside your if statement to check if the conditions are valid or not.
g_form.setValue('field_sales_sales_rep','true');
g_form.setValue('field_sales_inside_support','true');
g_form.setValue('field_sales_administration','true');
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 10:49 PM
Hi Siva,
your script on screenshot does not matches the fields you are also showing so it is a bit hard to debug.
My remark - you're checking the "United states" but normally the getValue is returning the value, not the Label (or a sysID if it is a reference), so make sure the value is not something like "united_states".
Additionally to debug it I would do something like this in the script (define variables separately so the condition then is easier to read and debug)
+ keep in mind to include the else branch to uncheck the checkboxes again in case the user select one option and then other so you don't get unexpected results
var isLocationCodeEmpty = g_form.getValue('please_select_the_location_code_UnitedStates') == '';
var isRequest1 = g_form.getValue('select_the_type_of_request') == '1';
var isCountryUS = g_form.getValue('please_select_the_country') == 'United States';
/* debug section
g_form.addInfoMessage(isLocationCodeEmpty);
g_form.addInfoMessage(isRequest1 );
g_form.addInfoMessage(isCountryUS );
*/
if ((isLocationCodeEmpty && isRequest1) && isCountryUS) {
g_form.setValue()
}