email script in CC - Requestor's manager,   Assignment Group members

PujithaB
Tera Contributor

Hi Everyone,

 

In email script I have to populate Requestor manager and assignment group members in CC

  • CC - Requestor's manager,   Assignment Group members
4 REPLIES 4

anshul_goyal
Kilo Sage

Hello @PujithaB,

you can use email script and do this and include that email script in your email body

I hope you are aware on how to include email script in email body

Scripting Email Notifications in ServiceNow

I assume assignment_group field is on current table and notification is also on same table

 

var group = current.assignment_group;

var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", group);
gr.query();
while(gr.next()) {
   email.addAddress("cc", gr.user.email.toString(), gr.user.name.toString());
}

email.addAddress("cc", current.requested_for.manager.toString(), current.requested_for.manager.name.toString());


Please mark my response as Accepted and Helpful for future references.

Thanks

Using this code, only assignment group members are populated.

Requestors name not populated.

Can you share your script? @PujithaB 

Unique45
Mega Sage

Hello @PujithaB 

You can achieve this using below code:

var group= new GlideRecord("sys_user_grmember");
group.addQuery("group", current.assignment_group);
group.query();
while(group.next()) {
   email.addAddress("cc", group.user.email.toString(), group.user.name.toString());
}
 email.addAddress("cc", current.requested_for.manager.email.toString(), current.requested_for.manager.name.toString());

 

 

Please mark correct/helpful if this helps you!