How to add Multiple Groups in the CC in email notification ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2023 02:27 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2023 02:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2023 02:45 AM
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’);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2023 04:30 AM - edited 06-22-2023 11:04 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2023 09:02 AM
@Community Alums @Any update?