Mail Script CC not getting added (Requested for & Assigned to Manager)

JerushaB
Tera Contributor

Hi ,

I am facing an issue with adding users to the CC field through a Mail Script in ServiceNow notifications.

I need to dynamically add the following users in CC:

  1. Requested For
  2. Assigned To → Manager

The notification triggers successfully and the email is sent only to assigned_to, but the CC recipients are not being added.

Mail Script Code Used
(function runMailScript(current, template, email, email_action, event) {

 

    gs.info('[Mail Script] Script execution started');

 

    // CC Requested For
    if (!gs.nil(current.requested_for) && !gs.nil(current.requested_for.email)) {
        email.addAddress(
            'cc',
            current.requested_for.email.toString(),
            current.requested_for.name.toString()
        );
    }

 

    // CC Assigned To → Manager
    if (!gs.nil(current.assigned_to) &&
        !gs.nil(current.assigned_to.manager) &&
        !gs.nil(current.assigned_to.manager.email)) {

 

        email.addAddress(
            'cc',
            current.assigned_to.manager.email.toString(),
            current.assigned_to.manager.name.toString()
        );
    }

 

})(current, template, email, email_action, event);
Screenshot 2026-04-14 130218.png
 
Is there a recommended or supported alternative approach to dynamically add CC users?

Any insights or guidance would be greatly appreciated.

Thanks in advance.

3 REPLIES 3

Rakesh_M
Tera Guru

Hi @JerushaB ,

I have checked the mail script from my side and it is working fine.
Please ensure there are no spaces in the mail script name.

Could you please provide a screenshot of the email when it is sent?

 

J Siva
Kilo Patron

Hi @JerushaB 
Script looks good.

Also note that CC and BCC recipients are listed under the "Copied" field in the email log, not under the "Recipients" field.
JSiva_0-1776155259724.png

Regards,
Siva

PrashantLearnIT
Tera Sage

Hi @JerushaB 

 

You can refer below my Video related to your issue: 

https://www.youtube.com/watch?v=InOWKzzev50&list=PLmMLNh-9xqQGsHBHuqOysMzvzha1kDq39&index=46

********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************
For More Information, please check details below: In this session, I have explained how we can Send an Email as cc & bcc in ServiceNow. ====================Email Scripts====================== (function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template, /* Optional ...