Some PDIs are currently unavailable, and PDI actions are paused. View the latest updates here. Read More

Make Case watchlist into email CC using Email script. how we can approach?

MUDIGOLAM BHANU
Tera Contributor

I want to make cc watchlist into email CC. How we can achieve using email script?

10 REPLIES 10

Tanushree Maiti
Tera Patron

Hi @MUDIGOLAM BHANU 

 

Can you try with this code snippet:

 

if (!current.watch_list.nil()) {
    var watchSysIds = current.watch_list.split(",");
     var len = watchSysIds.length;
     for(var i = 0; i!=len; i++) 
      {
        if(watchSysIds[i].toString().indexOf("@") > -1) 
         {
            email.addAddress("cc", watchSysIds[i], watchSysIds[i]);
        }else
          {                  
            var notifyUsr = new GlideRecord("sys_user");
            notifyUsr.addQuery("sys_id", watcherIds[i]);
            notifyUsr.addQuery("notification", 2); 
            notifyUsr.addQuery("email", "!=", "");
            notifyUsr.query();
            while (notifyUsr.next()) 
          {
            email.addAddress("cc", notifyUsr.email, notifyUsr.getDisplayValue());
            }
        }
     }
}     

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti