- 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
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
10-29-2019 12:10 AM
Wow. I can't even believe it was THAT SIMPLE. Thank you Vignesh!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2020 08:03 AM
Hi Vignesh,
I hope you're doing well.
Do I create an inbound email action in order to add CC'ed users to the watch list with the code you have provided? I'm brand new on the platform so I would appreciate your expertise.
Thanks,
Preet

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2020 08:35 PM
Hi preet,
You can update the existing actions to get this working.