List Collector

dev_K
Tera Contributor

Hello,

 

 

In my catalog item I use a list collector.

 

 

How this type of field is returned?

 

Is it an array or a string?

 

 

How can I check it?

Any examples? 

2 REPLIES 2

Sandeep Rajput
Tera Patron
Tera Patron

@dev_K A list collector returns a comma (,) separated list of strings (it can be sys_ids or choice values).  You can use .split() method to convert this string into an array. 

 

Here is an example  

62826bf03710200044e0bfc8bcbe5df1,5137153cc611227c000bbd1bd8cd2007,sampleuser@test.com

 

For more information please refer to https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0596181

 

Hope this helps.

Zach Koch
Giga Sage
Giga Sage

It depends on where you are returning those values for use. In a flow, using the Get Catalog Variables action on a list collector will return a string, which you will need to convert to an array. In the case of code, it will return it as an array. If you want to check this, when you are coding to grab this value, you can log the value with typeof to get what data type it is.

For example:

 

var test = current.variables.<my_list_collector>

gs.info(typeof test)

 

 

If this information helped resolve your issue, please remember to mark response correct and thumbs up to help future community members on this information, thanks!