how to push user x value to watchlist field on 106 incident tickets where watchlist contains user Y

amita2
Tera Contributor

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.

1 ACCEPTED SOLUTION

SanjivMeher
Kilo Patron
Kilo Patron

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.

View solution in original post

1 REPLY 1

SanjivMeher
Kilo Patron
Kilo Patron

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.