Add users to CC field in email?

Edwin Fuller
Tera Guru

I need to add two users to the CC field of an approval email notification template. I was told to use mail script but not sure how to write the script, any thoughts? The two field I need to add are "Primary Triage" and "Back Up Triage" which both are reference field to the sys_user table.

Thanks,

Edwin

1 ACCEPTED SOLUTION

If that is the case use this script. MAke sure your field names are correct



(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,


/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,


/* Optional GlideRecord */ event) {



  var ids=current.sysapproval.<primary triage>+','+current.sysapproval.<backup triage>;


  var user = new GlideRecord("sys_user");


  user.addQuery("sys_id","IN",ids);


  user.addQuery("email", "!=", "");


  user.query();


  while (user.next()) {


  //add to cc list


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


  }



})(current, template, email, email_action, event);


View solution in original post

20 REPLIES 20

Abhinay Erra
Giga Sage

I mean Fuji, geneva, helsinki?


Sorry - I'm on Helsinki


Then you email script should be this. Make sure you put your field names below.



(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,


/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,


/* Optional GlideRecord */ event) {



  var ids=current.<primary triage>+','+current.<backup triage>;


  var user = new GlideRecord("sys_user");


  user.addQuery("sys_id","IN",ids);


  user.addQuery("email", "!=", "");


  user.query();


  while (user.next()) {


  //add to cc list


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


  }



})(current, template, email, email_action, event);


Still not working for me not sure what is wrong!!



find_real_file.png


find_real_file.png


find_real_file.png


Make sure your field names are correct primary_traige and back_up_triage