How to add users from watch list to the CC of email notification
This content was last updated in 2023. It may still be useful, but could contain outdated information. Please confirm its accuracy before relying on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 03:18 AM
Hi all,
I have a requirement where i need to add all the watchlist users to the CC of email notification.
I have written the mail script but not getting the outcome.
Could someone help me on this.
Tried putting logs.
Log inside while loop is not coming.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 03:36 AM
@Rutusha Hi! Use below-
current.watch_list +=email.copied;
or
current.watch_list = current.watch_list + ',' +email.copied;
Please mark it helpful if it helps.
Thanks,
Sonia
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 03:45 AM
HI @SoniaShridhar13 - No luk still not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 03:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 03:46 AM - edited 08-28-2023 03:47 AM
Hi @Rutusha,
Use this script in your email script:
if(!current.watch_list.nil()){
//get watch list addresses and add to cc
var watcherIds = current.watch_list.split(",");
//get user records
var user =new GlideRecord("sys_user");
user.addQuery("sys_id", watcherIds);
user.addQuery("notification",2);
//email
user.addQuery("email","!=","");
user.query();
while(user.next()){
//add to cc list
email.addAddress("cc", user.email, user.getDisplayValue());}}From: Example scripting for email notifications (servicenow.com)