Set value for List Collector

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2014 06:20 AM
Hi all
I did write a script which shall do something like "setValue('collectorName', valueArray);" for List Collectors. There is already a script available @ http://www.servicenowguru.com/scripting/client-scripts-scripting/move-list-collector-options/. That script does not work if the selected values are not part of the initial loaded list - this happens if you point the List Collector to a table with many records (> 100 by default).
So far I do have got the following code to load a bunch of users to the right side of the List Collector:
function setSysUserCollectorValues(collectorName, selectedOptionsArray) { var documentFragment = document.createDocumentFragment(); for (var i = 0; i < selectedOptionsArray.length; i++) { var gr = new GlideRecord('sys_user'); if (gr.get(selectedOptionsArray[i])) { var option = document.createElement("option"); option.text = gr.user_name; option.value = selectedOptionsArray[i]; documentFragment.appendChild(option); } } var rightBucket = document.getElementById(collectorName + '_select_1'); rightBucket.options.length = 0; rightBucket.appendChild(documentFragment); eval(collectorName + 'acRequest(null)'); }
This is the script I use to reset the List Collector:
function resetCollectorValues(collectorName) { var leftBucket = document.getElementById(collectorName + '_select_0'); leftBucket.options.length = 0; var rightBucket = document.getElementById(collectorName + '_select_1'); rightBucket.options.length = 0; }
- Is there a more elegant way to solve this? I would like to get rid of the fixed glide record to the sys_user table and the eval() function.
- It looks like the "no_filter" attribute does not work anymore with my code above. Why does it show the filter again after applying these scripts?
- Is there an out of the box feature to perform this operation?
Regards
-Luca.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2015 12:46 AM
Hi Dalton
moveSelectedOptions() is an undocumented? function of ServiceNow. It will move
- the sys_ids (parameter 1)
- to bucket (parameter 2)
- from bucket (parameter 3)
You have to specify parameter 2 and 3 to point to valid buckets. You can switch left and right bucket. I'm not sure about parameter 4 here.
To solve your issue I would write a script which does apply the collector filter and then move the sys_id (g_user.user_id) from right go left.
Happy coding!
-Luca.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2016 05:37 AM
Hi Luca,
This is a bit old topic already, but just had to work on this type of stuff...
I was able to copy this code and make it work for most parts. Set filter and even set value to the right works in some cases. But it doesn't seem to accept values that are not in the "prepopulated" list on the left, even if those values would match the filter.
So, my table has more than 5000 records to choose from and list only shows 100. Were you able to solve this issue, or did I just misunderstood something?
Thanks for the example so far, hope you can help me figure out the last part also.
Br,
--Mikko
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2017 02:44 AM
Hi Mikko,
exact same issue did you get to find a solution on your side ?
Thanks
Kind regards
Agathe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2017 09:33 PM
Hi,
Any Update on this??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2017 03:12 PM
Looks like this is fixed in Instanbul (patch 7) and Jakarta:
ServiceNow KB: Unable to set the value of a list collector using setValue() (KB0622779)