The CreatorCon Call for Content is officially open! Get started here.

add a group to the cc of a notification

NiloferS
Tera Contributor

NiloferS_0-1718380598335.png

I have written above email script. Not working as expected. Kindly suggest.

2 ACCEPTED SOLUTIONS

SN_Learn
Kilo Patron
Kilo Patron

Hi @NiloferS ,

 

Please try the below:

(function runMailScript(current, template, email, email_action, event) {

var grpmembers = new GlideRecord('sys_user_grmember');
grpmembers.addEncodedQuery('group=420ebf345893e100ac315518e955d88e'); //Replace with your group's sysid
grpmembers.query();
while(grpmembers.next()){
	email.addAddress('cc', grpmembers.user.email.toString());
}
})(current, template, email, email_action, event);

 

Please Mark My Response as Correct/Helpful based on Impact

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

View solution in original post

S Goutham
Tera Guru

Hi @NiloferS 

I would recommend having DL group for the group members and the email to be set on the group email of group record

SGoutham_0-1718382847820.png


 and use the below script in the mail script :

 

 email.addAddress("cc","<email_address_of_the_Group>");

 

 But still, you can proceed with manually adding a user using the script below

var grpmem = new GlideRecord('sys_user_grmember');
grpmem.addQuery('group','<sys_id of  group>'); //Replace with your group's sysid
grpmem.query();
while(grpmem.next()){
	email.addAddress('cc', grpmem.user.email.toString(),grpmem.user.name.toString());
}

 

 

I hope this solves your issue
Mark this as Helpful / Accept the Solution if this clears your issue

View solution in original post

2 REPLIES 2

SN_Learn
Kilo Patron
Kilo Patron

Hi @NiloferS ,

 

Please try the below:

(function runMailScript(current, template, email, email_action, event) {

var grpmembers = new GlideRecord('sys_user_grmember');
grpmembers.addEncodedQuery('group=420ebf345893e100ac315518e955d88e'); //Replace with your group's sysid
grpmembers.query();
while(grpmembers.next()){
	email.addAddress('cc', grpmembers.user.email.toString());
}
})(current, template, email, email_action, event);

 

Please Mark My Response as Correct/Helpful based on Impact

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

S Goutham
Tera Guru

Hi @NiloferS 

I would recommend having DL group for the group members and the email to be set on the group email of group record

SGoutham_0-1718382847820.png


 and use the below script in the mail script :

 

 email.addAddress("cc","<email_address_of_the_Group>");

 

 But still, you can proceed with manually adding a user using the script below

var grpmem = new GlideRecord('sys_user_grmember');
grpmem.addQuery('group','<sys_id of  group>'); //Replace with your group's sysid
grpmem.query();
while(grpmem.next()){
	email.addAddress('cc', grpmem.user.email.toString(),grpmem.user.name.toString());
}

 

 

I hope this solves your issue
Mark this as Helpful / Accept the Solution if this clears your issue