How do I modify a list collector?

RayRoulstone
Tera Expert

I have a record producer with a list collecter and I and need to change the selected options depending on the value of a drop-down list on the same record producer.

I have tried the script listed here https://www.servicenowguru.com/scripting/client-scripts-scripting/move-list-collector-options/ as a catalog client script, but this is not working. 

I have inserted some jslog entries into the script and it seems to fail at

var leftBucket = gel(varName + '_select_0');

The idea is to use a list collecter to create a task for each entry in the list collector. The drop-down provide a list of standard tasks for a set option then the list collector can be used to add or remove should it need to be customized.

Fairly new to SN development so go easy. I can, however, do some simple JS coding.

Thanks

Ray

1 ACCEPTED SOLUTION

Michael Jones -
Giga Sage

So, to be clear, you want to change the options that have been selected (moved to the right) based on some other form change? You can do this using g_form.setValue() but list collectors have a little twist; you need to supply a comma separated string of sys_id's that match the records displayed in the list collector. 

For example, say you have a list collector named "list" that references sys_user and you want to auto-populate two names in the list. You would find the sys_id's of the users and then do this: 

//List of sys_ids for users: 
var sys_users = '62826bf03710200044e0bfc8bcbe5df1,a8f98bb0eb32010045e1a5115206fe3a'

//set the values in the list collector
g_form.setValue('list', sys_users);

and there you go: 

find_real_file.png

 

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Cloudpires

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

View solution in original post

6 REPLIES 6

Make sure you are passing in the sys_id's of the records you would select in the list collector and that you are using the correct field name. 

If you want to check what values you should be passing, add an onchange for your list collector and alert g_form.getValue('your_field_name') 
to see what the string should look like. 

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

Ram70
Tera Contributor
function onLoad() {  
        var selectedIDs = '53958ff0c0a801640171ec76aa0c8f86,5f8af237c0a8010e01a932999468b83a';
        g_form.addInfoMessage("right bucket testing" + selectedIDs);
        g_form.setValue('ci_values', selectedIDs);
}
 
Tried based on the post, but it is not working.