Script to add cc'd users to watch list

mkader
Kilo Guru

Hello,

I need to create an inbound action that auto populates the watch list with  cc'd user(s) for RITMs. How can I do this? If a cc'd user does not exist in the system, I do not want to create a new user

Thanks!

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

Within this inbound action, in the script section, you can retrieve the "copied" users (aka CC'd) which will give you a comma separated string of their email address. From there, you can query your sys_user table to find a match based off of this and if found, add them to your watch list.

Something like:

var copied = email.copied;
var watchList = current.watch_list;
var findMem = new GlideRecord('sys_user');
findMem.addQuery('email', 'IN', copied);
findMem.addQuery('sys_id', 'NOT IN', watchList);
findMem.query();
while (findMem.next()) {
current.watch_list += "," + findMem.sys_id;
}
current.update();

I just tested this myself and it does work. So as long as your inbound action has found the correct record to associate the email to, this will work just fine.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

23 REPLIES 23

Ashley Snyder1
Giga Guru

Here's an old wiki article you may be able to re-purpose: https://old.wiki/index.php/Add_All_Email_Recipients_to_Watch_List

@Ashley Snyder - Thanks for your response. I will test this out. Thanks

Allen Andreas
Administrator
Administrator

Hi,

Within this inbound action, in the script section, you can retrieve the "copied" users (aka CC'd) which will give you a comma separated string of their email address. From there, you can query your sys_user table to find a match based off of this and if found, add them to your watch list.

Something like:

var copied = email.copied;
var watchList = current.watch_list;
var findMem = new GlideRecord('sys_user');
findMem.addQuery('email', 'IN', copied);
findMem.addQuery('sys_id', 'NOT IN', watchList);
findMem.query();
while (findMem.next()) {
current.watch_list += "," + findMem.sys_id;
}
current.update();

I just tested this myself and it does work. So as long as your inbound action has found the correct record to associate the email to, this will work just fine.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

@Allen A  Thank you for your response. I will try to recreate this in my PDI to see and make modifications as needed. This looks like it may do the job as provided. Should I set the inbound action up like this:

find_real_file.png

Or should I relate it to an existing inbound action?