The CreatorCon Call for Content is officially open! Get started here.

Need to push User values from Array to a List collector field in ServiceNow?

micky09
Tera Contributor

I have a requirement where we have a custom table with two fields first is Meeting Room which is String type another one is Delegate which is a List Collector Field.

We have catalog for Meeting room creation which is to be automated so via script i need to create Meeting Room Records in this Custom table, how i can push the user multiple user values from an array to this List collector ?

Any help will be appreciated..

2 REPLIES 2

Mike Patel
Tera Sage

What type of variable it is for users.

if it stores user's sys id than you can just say

gr.XXXX = current.variables.XXXXX;

 

Tony DiRienzo
Giga Guru

The List collector stores values as a comma separated string, so just use Array.join() to convert the array of user sys_ids into a comma separated string.  Something like this:

var userArray = ["<sys_id of first user>", "<sys_id of second user>", ... "<sys_id of nth user>"];
current.setValue("u_delegates", userArray.join());
current.update();