How to Copy list collector values to string field using BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2023 04:05 AM
Hi Team,
How to Copy List Collector values to String field using BR
When the List collector values changes copy new values to string field in sys_user_group Table
Thank you,
Anil!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2023 04:23 AM
If you truly mean List Collector values, then it's just
current.new_field_name = current.list_field_name;
You'll find that the value of a List Collector field is a comma-separated list of sys_ids for the referenced table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2023 04:24 AM
Hi,
Create a before update business rule when list collector value changes
Write below in advanced script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2023 04:35 AM
you can use before insert/update BR
Script will be like this
current.setValue('fieldName', current.listField.getDisplayValue());
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2023 05:08 AM - edited 12-15-2023 05:09 AM
current.<string_field_name>= current.<list_variable_name>;
It will give you the sys_ids in comma separated If you wnat name then look below:
var sys_ids = current.<list_field_name>;
var arr = [];
var ids = sys_ids.split(",");
for(var i=0;i<ids.length;i++)
{
var gru = new GlideRecord("sys_user"):
gru.addQuery("sys_id", ids[i]);
gru.query();
if(gru.next())
{
arr.push(gru.full_name);
}
var final = arr.toString();
current.<list_field> = final;
}
Regards,
Shamma