List Collector
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 06:26 AM
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 06:31 AM - edited 06-07-2024 06:32 AM
@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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 06:32 AM - edited 06-07-2024 06:32 AM
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)