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 Sage

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 mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: