How to update list value in servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2020 02:23 AM
How to update list field using background script, will set value will work here?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2020 02:29 AM
You can try with below code.
var gr = new GlideRecord('<table name>');
gr.get('<sys id of record>'); // for an example
gr.<list field name>= 'sys_id of that value'; // list type accept sys_id because it refer to a table.
gr.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2020 02:30 AM
Yes, just use a String of comma separated values.
So something like this:
(function executeRule(current, previous /*null when async*/) {
var valuesToSet = [];
valuesToSet.push(current.assigned_to.toString());//example to add assigned to
valuesToSet = new ArrayUtil().unique(valuesToSet);
current.u_test = valuesToSet.toString();
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2020 02:30 AM
Yes just like you set reference value do it here via GlideRecord. It will work.
Thanks
Sudhanshu

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2020 02:32 AM
Hi Sathwik,
Insteas of background script did you try editing it from list view?
If you tried & it did not work then it is because of system property: glide.ui.list_edit_ignore_types
Look for the property from System properties table & remove the 'list' from the Value field.
Once done try editing/updating records from List view & it should work.
Since, it a global property modifying it would mean it make fields of type List to be editable across tables.