How to populate list collector variable based on checkbox selection(s)?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi all,
I have been trying to satisfy a request regarding list collector on a catalog Item.
I have created multiple checkboxes and a list collector variable. The expectation is that, If I select checkbox A, the related group would be populated on list collector. If I select checkbox A and Checkbox B, the related groups would be populated on list collector.
My initial opinion was creating a custom table to be able to run catalog data lookup to populate list collector. But It does not seem to be working. (I am not sure, If this is related with checkbox variable)
That's why, I am trying to find another solution and help.
Thanks for your reply and help in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
you can use system property to hold the mapping
Then you can use onChange on each of those checkboxes and use GlideAjax to populate list collector.
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
18 hours ago
Thank you for marking my response as helpful.
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
yesterday
There are 2 ways to do it.
1) Depending upon the value you can use it in script include to get the response back using client script and in the client script you can return/set the value
2) On the List Collector variable - you can set the attribute ref_qual_elements=<field name> and use advance condition to set the value.
if you provide more details about the value in the selection and what should should on list collector ,
i can assist in building something
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday - last edited yesterday
Hi @Alp Utku
To fill the list colector may you use a onChange script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) return;
var newArr = [];
// If Checkbox A is checked → add Group A sys_id
if (g_form.getValue('chk_A') == 'true') {
newArr.push('sys_id_of_group_A');
}
// If Checkbox B is checked → add Group B sys_id
if (g_form.getValue('chk_B') == 'true') {
newArr.push('sys_id_of_group_B');
}
// If Checkbox C is checked → add Group C sys_id
if (g_form.getValue('chk_C') == 'true') {
newArr.push('sys_id_of_group_C');
}
// Update list collector with array of sys_ids
g_form.setValue('lc_groups', newArr.join(','));
}
I suggest that you use GlideAjax to get those groups that you need