- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hello.
We have a new user on the support team. How do I update an existing watchlist with this new user so he is notified when a new incident is created, or an existing incident is updated/closed?
Is there a way to do this without running a script?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
That's great @Wayne DeCoste ,
Can you please mark the solution as accepted/helpful so that it helps future readers.
That will be much appreciated 🤗!
Shashank Jain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
FYI - I tried running my query through GPT and it suggested:
var gr = new GlideRecord('incident');
gr.addQuery('active', true); // filter as needed
gr.query();
while (gr.next()) {
// Append without overwriting
var currentWatch = gr.watch_list ? gr.watch_list.split(',') : [];
var newUser = '6816f79cc0a8016401c5a33be04be441'; // sys_id of user
if (currentWatch.indexOf(newUser) === -1) {
currentWatch.push(newUser);
gr.watch_list = currentWatch.join(',');
gr.update();
}
}
But, not being a java guy, Im not sure of this accomplished what I am trying to do ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
And, I dont want to overwrite the existing watchlist, just append.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Use this script, It will update the watchlist if the user is not present in there.
var userToAdd = 'a8f98bb0eb32010045e1a5115206fe3a'; // sys_id of the user
var gr = new GlideRecord('incident');
gr.addQuery('active', true);
gr.query();
while (gr.next()) {
var currentWatchlist = gr.getValue('watch_list') || '';
var watchlistArray = currentWatchlist.split(',').filter(Boolean);
if (watchlistArray.indexOf(userToAdd) == -1) {
watchlistArray.push(userToAdd);
gr.setValue('watch_list', watchlistArray.join(','));
gr.update();
gs.print(gr.number + " updated watchlist: " + gr.watch_list);
} else {
gs.print(gr.number + " already had the user in watchlist");
}
}
Shashank Jain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Good morning! And thank you.
So, this script will update any existing incidents, and add the user to any new incidents that are created?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
@Wayne DeCoste , Good morning!
It will update the existing incidents watchlist.
Shashank Jain