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

Alp Utku
Mega Sage

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. 

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Alp Utku 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Alp Utku 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

rajesh9885
Mega Guru

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

Rafael Batistot
Tera Sage

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(','));
}

 

https://www.servicenow.com/community/developer-forum/populate-list-collector-variable-from-catalog-c... 

I suggest that you use GlideAjax to get those groups that you need