- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 10:02 AM
My requirement is to update a user X(new record) in incident records (say 106) which is active and where watchlist contains user Y
so query is like active=true^watch_listLIKExxxxd882b1ab900cf0a914c59dxxxx
I want to do below :
move watch list in array
Then split the array
Then you have to run a loop to check each record for in array with this sys id
And where it matches then you have in that expense records array you have to add one more value
And update watch list with new array
Please assist with script.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 10:16 AM
You can do something like this
var inc = new GlideRecord('incident');
inc.addEncodedQuery('active=true^watch_listLIKExxxxd882b1ab900cf0a914c59dxxxx');
inc.query();
while (inc.next())
{
inc.watch_list= inc.watch_list+','+'<the sysid of x>';
inc.update();
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 10:16 AM
You can do something like this
var inc = new GlideRecord('incident');
inc.addEncodedQuery('active=true^watch_listLIKExxxxd882b1ab900cf0a914c59dxxxx');
inc.query();
while (inc.next())
{
inc.watch_list= inc.watch_list+','+'<the sysid of x>';
inc.update();
}
Please mark this response as correct or helpful if it assisted you with your question.