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

Community Alums
Not applicable

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" 

13 REPLIES 13

@Community Alums 

See if you don't have group email i'd then you can write the each member name and email i'd in email-script .

cc.png

Community Alums
Not applicable

If there are 100 members in the group then we can't mention 100 member 

seethapathy
Giga Guru
Hi @Community Alums 
if you have group email id follow below method
 
email.addAddress("cc", "group mail id","Jgroup name");
email.addAddress("bcc", "group mail id","Jgroup name");
 
if indivdual recipent email script should be like this
 
(function runMailScript(current, template, email, email_action, event) {
 
email.addAddress('cc',current.recipient.email.toString(),current.recipient.name.toString());
 
})(current, template, email, email_action, event);
 
If helpful Mark it as helpful

 

Community Alums
Not applicable

Hi @seethapathy 

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" 

 if you have multiple recipients try below script in email script

if(!current.recipient.nil()){

var watcherIds = current.recipient.split(",");

var user =new GlideRecord("sys_user");

user.addQuery("sys_id", watcherIds);

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

user.query();

while(user.next()){

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

}

}

if this script is helpful mark it as helpful and accepted solution