Getting selected values in a list collector catalog variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2016 11:25 AM
One of the variables in my catalog item is a list collector. This list collector permits users to select records (move from left to right) to be de-activated. Upon submit (I will use a On Submit client script), I want to loop through the selected value(s) in the list (right-side of the list); then I will find the appropriate record in the table and set Active = false. I know how to update the record (GlideRecord), and how to code a loop, but I am not certain how I get the Selected values into an arry. Thanks!
Ric

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2016 11:33 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2016 11:50 AM
Hi Ric,
The values of the list variable are stored in a comma separated list of sys_ids. To get that in to an array, you only need to split(). Something like this
var myList = g_form.getValue('my_variable');
var myArray = myList.split(',');
for (var i = 0; i < myArray.length; i++) {
var gr = new GlideRecord('my_table');
if (gr.get(myArray[i])) {
// Do what you want to the retrieved record
}
}
Hope that helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2016 12:01 PM
I tried both methods and both worked perfectly! Thank you very much.
Ric

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2016 12:05 PM
Thanks Ric for the update.
Would you mind marking answer as correct and close the loop.
P.S. Some users do not see the Correct Answer link (per this video at 20:00 https://community.servicenow.com/thread/224893). Let me know if you do not see it and I can get a community moderation to assist.