How to add a group in "CC" in an Email Notification?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2024 01:33 AM
Hi,
I have one requirement: I need to add a group to the 'CC' in an email notification using an email script.
Note that - this group doesn't have an email ID, so I need to send the email to the individual members of the group.
For example, if there is a group called 'Global' with five members, I need to add those five members to the "CC"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2024 02:59 AM
You may try using within the script:
email.setCc('abc@xyz.com', 'pqr@xyz.com');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2024 04:44 AM
Hello @Community Alums ,
Can you please try this email script and let me know whether it is useful or not.
// Get the group from the current record dynamically (e.g., assigned group on an incident or task)
var groupSysId = current.assigned_group; // Replace 'assigned_group' with the correct reference field
if (groupSysId) { // Check if the group field is not empty
var group = new GlideRecord('sys_user_group');
if (group.get(groupSysId)) {
// Loop through all the members of the group
var groupMembers = new GlideRecord('sys_user_grmember');
groupMembers.addQuery('group', group.sys_id);
groupMembers.query();
// Check if there are members in the group
if (groupMembers.hasNext()) {
while (groupMembers.next()) {
// Dynamically print each member's email
template.print(groupMembers.user.email + ', ');
}
} else {
gs.log('No members found in the group: ' + group.name);
}
} else {
gs.log('Group not found with sys_id: ' + groupSysId);
}
} else {
gs.log('No group is assigned to this record.');
}
Thanks
SP.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2024 04:45 AM
Hi @Community Alums,
You may try with the following mail script.
Script :
and in Notification Body just add:
Please mark my response as correct and helpful if it helped solved your question.
Thanks,
Rohit Suryawanshi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2024 05:46 AM
Hi @Community Alums,
You can write the email script and call email script in notification.
Refer below code:
In Notification Body add - ${mail_script:<Your script name>}
e.g: ${mail_script:test_email_script}
Email Script -
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful."
Thanks!