- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2019 11:57 PM
Hello,
I am looking to implement functionality that will add CC'd users from email to watchlist automatically. I've found couple of topics here and used following code. While it works fine, it also adds users from "To" field of the email (so in my case our instance email address). Is it possible to limit this so only CC'd users are added and not users from "To" field?
//populate watchlist from cc filed
var wList = current.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];
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;
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2019 12:01 AM
What happens when you just try
current.watch_list +=email.copied;
or
current.watch_list = current.watch_list + ',' +email.copied;
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2021 10:29 AM
Hello Vignesh,
Love the simplicity and it works well! How can I expand the code so that it validates against my sys_user table and only enter those addresses? Do not want outside addresses added to the watchlist.
Thank you,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2021 11:49 AM
Answered mu inquiry with the following script. Please note that if your sys_user detects multiple entries associated to the email address of a value in the CC audience, those multiple entries will be added to the watchlist regardless of the fact that they do not exist in the CC field (IE: if CC: Susan and sys_user identifies Susan's email is tied to Wadsworth and Victoria; then Wadsworth and Victoria will be added to the watchlist although they were not in the original email's CC field)
//populate watchlist from cc field
var wList = current.watch_list;
var rarray = email.recipients_array;
for (var i = 0; i < rarray.length; i++) {
var recipient = rarray[i];
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);
wList = recipient;
}
}
}
//}
current.watch_list = wList;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2022 01:38 AM
Hi VignesMC,
Appreciate for the answer and it's work!.
Would like to drop another request, if the Worklist user add another person in cc during the reply ,the worklist will not be added in the incident unless the caller itself add the new person in CC (it will add the new CC as a worklist user).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2020 08:40 AM
@Dawid
where this particular code should be written? even i have the same requirement? can you please tell me?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2020 09:51 AM
Hi Thousif,
It depends how you control ticket creation from email. We have inbound actions, but within these inbound action we have reference to script include which actually handles incident creation.
So it will be either inbound action or script include associated with this inbound action.