how to add dynamically cc to email notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2023 12:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2023 12:33 AM - edited ‎05-25-2023 12:34 AM
Hi @kandunurimahesh ,
To dynamically add cc, create an email script and use below code in that script (Add condition appropriately)
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var user = new GlideRecord("sys_user");
user.addQuery("sys_id", current.caller_id); // Apply your filter to get user
user.query();
while(user.next()){
email.addAddress("bcc",user.getValue('email_address'),user.getValue('name'));
email.addAddress("cc",user.getValue('email_address'),user.getValue('name'))
}
})(current, template, email, email_action, event);
Now you can call the above mail script in email notification body as ${mail_script:script name}
Here replace script name with the exact name of the notification email script you have created initially
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2023 12:37 AM
Hello @kandunurimahesh ,
You can create email script and use below API to add cc in a notification.
email.addAddress("cc", emailaddress, addressname);
Please verify below email script for reference:
Email Script:
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
email.addAddress("cc", current.u_manager.email.toString(), current.u_manager.name.toString());
})(current, template, email, email_action, event);
If my answer helped you in any way, please then mark it as helpful.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2023 01:12 AM - edited ‎05-25-2023 02:17 AM
When ever an event is triggered via notification the notification is going to the given user ..But I want to add the manager in the cc dynamic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2023 01:18 AM
first we have to creat event registry
next event regisrty we hav to call in business rule(
)
next we have to create notification
next we will creat mail script and we will add in notification in html body ${mail_script:script name}
is this correct way to create
can u provide clear steps