Duplicate users Watch List
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2022 09:08 AM
I added this to my inbound email actions to add users who are CC'd on an email to the watchlist of an incident/request:
current.watch_list = current.watch_list + ',' +email.copied;
This works great, only issue is it will infinitely add duplicates to the watch list as emails are exchanged and people are cc'd.
Any ideas?
Here's the full script for reference:
gs.include('validators');
if (current.getTableName() == "incident") {
current.watch_list = current.watch_list + ',' +email.copied;
var gr = current;
if (email.subject.toLowerCase().indexOf("please reopen") >= 0)
gr = new Incident().reopen(gr, email) || gr;
gr.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
if (gs.hasRole("itil")) {
if (email.body.assign != undefined)
gr.assigned_to = email.body.assign;
if (email.body.priority != undefined && isNumeric(email.body.priority))
gr.priority = email.body.priority;
}
gr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2022 09:23 AM
Hi,
You can change this line to:
current.watch_list = current.watch_list + ',' +email.copied;
change to...
var u = current.getValue('watch_list') + ',' + email.copied;
var array = u.split(',');
var arrayUtil = new global.ArrayUtil();
var finalArray = arrayUtil.unique(array);
current.watch_list = finalArray.toString();
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2022 11:20 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2022 11:32 AM
Hi,
My apologies, I don't know how your script ended up looking.
Perhaps you could provide us with an update?
Please mark reply as Helpful, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2022 11:41 AM
Sure thing, appreciate the help.
gs.include('validators');
if (current.getTableName() == "incident") {
var u = current.getValue('watch_list') + ',' + email.copied;
var array = u.split(',');
var arrayUtil = new global.ArrayUtil();
var finalArray = arrayUtil.unique(array);
current.watch_list = finalArray.toString();
var gr = current;
if (email.subject.toLowerCase().indexOf("please reopen") >= 0)
gr = new Incident().reopen(gr, email) || gr;
gr.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
if (gs.hasRole("itil")) {
if (email.body.assign != undefined)
gr.assigned_to = email.body.assign;
if (email.body.priority != undefined && isNumeric(email.body.priority))
gr.priority = email.body.priority;
}
gr.update();
}