
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2016 08:49 AM
I found the script below at http://wiki.servicenow.com/index.php?title=Useful_Inbound_Email_Scripts#gsc.tab=0http://
It adds the cc'd users to the watch list, but it also created another incident with the same incident number. Not sure what I am missing.
// Add All Email Recipients to Watch List
var wList = current.watch_list;
var gList = current.u_group_watch_list;
var rarray = email.recipients_array;
var instanceEmail = gs.getProperty('glide.email.user');
for (var i = 0; i < rarray.length; i++) {
var recipient = rarray[i];
//Check to see if this is a group address...and if so add to the group watch list
var grp = new GlideRecord('sys_user_group');
grp.addQuery('email', recipient);
grp.query();
if (grp.next()) {
if(gList != "") {
gList = (gList + "," + grp.sys_id);
} else {
gList = grp.sys_id;
}
} else {
//It's not a group address...so check to see if it's a user
var gr = new GlideRecord('sys_user');
gr.addQuery('email', recipient);
gr.query();
if (gr.next()) {
// It's a user
if(wList != "") {
wList = (wList + "," + gr.sys_id);
} else {
wList = gr.sys_id;
}
} else {
//It's not a user either...so just add the address to the list...except instance email address
if (recipient != instanceEmail) {
if(wList != "") {
wList = (wList + "," + recipient);
} else {
wList = recipient;
}
}
}
}
}
current.watch_list = wList;
current.u_group_watch_list = gList;
current.insert();
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2016 01:08 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2016 11:23 AM
Eric,
Try to remove the current.insert() at the last statement and check if it fixes the issue

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2016 12:03 PM
removing current.insert(); resulted in the users not being added to the watch list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2016 01:08 PM
Eric,
My apologies replace current.insert() with current.update()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2016 05:44 AM
That change worked. Thank you.