Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Add User in CC of an email

may13
Tera Contributor
Hello,
I have a requirement in my current project where I need to create an email script in ServiceNow. In the User table, I have three custom fields: L1 Approval, L2 Approval, and HR Employee. I need to include the users from these fields in the CC section of a notification. Could you please provide the email script?

 

11 REPLIES 11

Raghav Sharma24
Giga Patron

what is the table of your notification. L1, L2 and FR will be based on some user for example requested for.

 

var ccEmails = current.requested_for.L1_approval +"," + current.requested_for.L2_approval + ","+ current.requested_for.hr_employee.

 

email.addAddress('cc' ,ccEmails) ;
 
You need to update the fieldnames/variables as per your need. requested_for, L1_approval etc have to be your field names.
 

@Raghav Sharma24     

The table is HR Profile, and this notification will be received by the user.
and in CC we need to add L1 ,L2 and HR 

Notification will be sent from which table? sn_hr_core*?

The code i suggested will work, just replace the variable and field names.

nayanmule
Kilo Sage

@may13  , This is very simple.

Create a new mail script with any name.

 

Add a script in the mail script 

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

 Replace current.requester.manager.email with your fields name like - current.approval1, current.approval2.

 

Call the Script in Your Notification:

  • Go to the notification (e.g., Incident [sys_notification]) you want to modify.
  • In the What it will contain tab, find the Message HTML (or Plain Text) field.
  • Add your email script as ${mail_script:your_email_script_name}  

 

Follow this for more information - How to add CC in an email notification  

https://www.servicenow.com/community/developer-articles/send-an-email-to-any-person-as-cc-bcc/ta-p/2...

 

If my response has helped you, kindly mark it as helpful and accept the solution.

Regards,

Nayan