Adding user manager as cc in email notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi Team,
We have created a scheduled script to send open incidents to all the technicians individually it is working and going html table report individually in one scheduled script but our use case while sending individual email we need to add cc or to address thier manager so we have created a email script and hardcoded on notification mentioned below screenshots we can able to get the logs by finding the manager but couldn't able to add cc so, please help on the above requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @HarshithK ,
Missing parameter in addAddress() method.
Follow the below script to modify the code:
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
email.addAddress('cc', mgr.email, mgr.name);
email.addAddress('bcc', gr.email, gr.name);
})(current, template, email, email_action, event);
Also, instead of using GlideRecord multiple times for getting user and manager details separately chekout addExtraField() method.
Thanks
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
if your event parm1 contains recipient then you are correct in your script, just update this line
email.addAddress('cc', mgr.email.toString(), mgr.name.toString());
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
hi @HarshithK ,
try with the
email script
(function runMailScript(current, template, email, email_action, event) {
// parm1 = technician sys_id
var userSysId = event.parm1;
if (!userSysId) {
gs.info('No user sys_id passed to email script');
return;
}
var user = new GlideRecord('sys_user');
if (user.get(userSysId)) {
if (user.manager) {
var mgr = new GlideRecord('sys_user');
if (mgr.get(user.manager)) {
email.addAddress('cc', mgr.email);
gs.info('✅ Manager added in CC: ' + mgr.email);
} else {
gs.info('⚠️ Manager record not found for user: ' + user.name);
}
} else {
gs.info('⚠️ No manager assigned for user: ' + user.name);
}
} else {
gs.info('⚠️ User not found for sys_id: ' + userSysId);
}
})(current, template, email, email_action, event);
notifications
<p>Hello ${event.parm2},</p>
<p>Please find the open incidents assigned to you below:</p>
${mail_script:Email_Manager_cc}