- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 07:06 PM
Hello,
I have received from multiple users need to be added in incident watchlist and work note list.
Simple way is open each one of the incident add user in watchlist and work note manually. But this approach requires a lot of time and effort.
What I am looking is fix script which adds user in the watchlist and work note list if certain condition met. At the moment, condition could be simple like Add "John" user to INC000001,INC000002,INC000003 incident's watchlist and work note list.
Thank you,
BR.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 07:58 PM - edited 04-04-2023 07:59 PM
Okay, you can use below:
var incNum = 'INC000001,INC000002,INC000003';
var usersID = 'c84ac7662f611d10ae17debcf699b6d3,681b365ec0a80164000fb0b05854a0cd'; // comma separated list of users sys_id
var incGr = new GlideRecord('incident');
incGr .addEncodedQuery('numberIN'+incNum); // replace your query
incgr.query();
while(incGr.next()){
var watch_list_user='';
watch_list_user = incGr.watch_list.toString();
incGr.watch_list = watch_list_user +','+usersID ;
incGr.setWorkflow(false);
incGr.update();
}
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 07:39 PM - edited 04-04-2023 07:39 PM
Hi,
You can try below:
var incNum = 'INC000001,INC000002,INC000003';
var usersID = 'c84ac7662f611d10ae17debcf699b6d3,681b365ec0a80164000fb0b05854a0cd'; // comma separated list of users sys_id
var incGr = new GlideRecord('incident');
incGr .addEncodedQuery('numberIN'+incNum); // replace your query
incgr.query();
while(incGr.next()){
incGr.watch_list = usersID ;
incGr.setWorkflow(false);
incGr.update();
}
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 07:55 PM
Hi Anil Lande,
It seems script works, but it erases all existing data in watch list field. Is there any way to preserve existing user info and add new user with fix script.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 07:58 PM - edited 04-04-2023 07:59 PM
Okay, you can use below:
var incNum = 'INC000001,INC000002,INC000003';
var usersID = 'c84ac7662f611d10ae17debcf699b6d3,681b365ec0a80164000fb0b05854a0cd'; // comma separated list of users sys_id
var incGr = new GlideRecord('incident');
incGr .addEncodedQuery('numberIN'+incNum); // replace your query
incgr.query();
while(incGr.next()){
var watch_list_user='';
watch_list_user = incGr.watch_list.toString();
incGr.watch_list = watch_list_user +','+usersID ;
incGr.setWorkflow(false);
incGr.update();
}
Thanks
Anil Lande