Include Watch list on SC_Task email

Lorna
Tera Contributor

Hello, I would like to include users that are added on watchlist to email cc column. I created an email script but I'm not seeing the users in the cc column when i try to send an email.

 

 

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());

      

      }

1 REPLY 1

Community Alums
Not applicable

Hello @Lorna  ,

 

Please try adding .toString() when setting the email addresses

email.addAddress("cc", user.email.toString(), user.getDisplayValue().toString);

 

And please refer to this:

https://www.servicenow.com/community/developer-forum/how-can-i-add-watch-list-users-to-cc-in-the-ema...

 

@Lorna  , Please mark my answer as "Accept as Solution" and "Helpfuls." If it works for you.

 

Thank You!