How to add Multiple Groups in the CC in email notification ServiceNow

Shital14
Tera Contributor

Hello Team,

I have two fields reference field on the form. On creation of Ticket i want add two Groups users in CC. Fields are  Approver and viewer both are referring to the Group Field.

 

how can i achieve these in serviceNow?

@Community Alums 

4 REPLIES 4

kalpesh9
Mega Guru

Hello @Shital14 

 

Please check below community link

 

https://www.servicenow.com/community/developer-forum/how-to-add-group-members-in-cc-there-are-2-grou...

 

Let me know if that is helpful

 

Thanks,

Kalpesh

Community Alums
Not applicable

Hi @Shital14 ,

To add email addresses to the cc or bcc field of an outbound email in ServiceNow, you can use a mail script and the email.addAddress method. To call the script on the notification, append ${mail_script:xxx}. You can add multiple email addresses by iterating through a while loop in the script.

${mail_script:xxx}

email.addAddress(‘cc’,’example@me.com’,’Example’);

Hello Sandeep.

I have tried below script condition is when new record is inserted and wrote below script in email notification and tried to called in Notification. But it's not working can check the below script? 

 

var list =[]
var username =[];
var useremail = [];

var gr = new GlideRecord('sn_risk_advanced_risk_assessment_instance'); gr.addQuery('number', current.number);
gr.query();
if(gr.next()) {
group_list.push(gr.approver_group);

 }

var groupMem = new GlideRecord('sys_user_grmember'); groupMem.addQuery('group.sys_id', 'IN', group_list.toString());

groupMem.query();
while(groupMem.next()) {
useremail.push(groupMem.user.email); username.push(groupMem.user.name);
}
email.addAddress(“cc”,useremail.toString());

 

it’s working fine from tha background script but email notification is triggering to group members.

 

what should I nèed to modify?

 

 

 

 

@Community Alums @Any update?