how to trigger notification Keeping Set of users or full users from group as CC in email notificatio

lakshmi_laksh
Tera Contributor

Hello,

I have a requirement, i need to send notification to all users of a particular group as CC.
anyone can help me on this
thanks in advance.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@lakshmi_laksh 

you will have to use email script and then iterate over sys_user_grmember table and use this line

email.addAddress("cc", "email", "name");

something like this

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

    // Add your code here
    var gr = new GlideRecord("sys_user_grmember");
    gr.addQuery("group.name", "Group ABC");
    gr.query();
    while (gr.next()) {
        email.addAddress("cc", gr.user.email.toString(), gr.user.getDisplayValue());
    }

})(current, template, email, email_action, event);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@lakshmi_laksh 

you will have to use email script and then iterate over sys_user_grmember table and use this line

email.addAddress("cc", "email", "name");

something like this

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

    // Add your code here
    var gr = new GlideRecord("sys_user_grmember");
    gr.addQuery("group.name", "Group ABC");
    gr.query();
    while (gr.next()) {
        email.addAddress("cc", gr.user.email.toString(), gr.user.getDisplayValue());
    }

})(current, template, email, email_action, event);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@lakshmi_laksh 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hello @Ankur Bawiskar ,
Thanks for the immediate response 
Tried the above script but it is not working, i do not see recipients in Copied on emails

Hello @Ankur Bawiskar ,

script worked
thanks a lot