Email Scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2024 06:25 PM
Hi everyone,
I am trying to create an email notification and the conditions are these -
* when incident's state is in progress and the assigned to is not empty
then I want to send an email to the "assigned to" user with their manager in cc
I am trying to this with email script and my email script is this...
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var assignedTo = current.assigned_to;
var manageremail = current.assignedTo.manager.email;
email.addAddress('to', assignedTo);
email.addAddress('cc', manageremail);
})(current, template, email, email_action, event);
I am not sure if the script is correct or not but I am trying and my "notification: what will it contain" email body is this...
${mail_script:in progess state}
Hello ${assigned_to.first_name},
${number} state is in progress.
Servicenow Team
Please help.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2024 09:38 PM
I hope this helps.
(function runMailScript(current, template, email, email_action, event) {
var assignedTo = current.assigned_to;
if (assignedTo && assignedTo.manager && assignedTo.manager.email) {
var managerEmail = assignedTo.manager.email;
email.addAddress('cc', managerEmail);
}
email.addAddress('to', assignedTo);
})(current, template, email, email_action, event);
mail Body:
Hello ${assigned_to.first_name},
The incident (${current.number}) is now in ${current.state.getDisplayValue()} state.
Servicenow Team
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2024 01:31 PM
Nope, It did not work as well
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2024 09:56 PM
@MohdF Please try the following.
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var assignedTo = current.assigned_to.toString();
var manageremail = current.assignedTo.manager.email.toString();
email.addAddress('to', assignedTo);
email.addAddress('cc', manageremail);
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2024 08:17 AM
Hi Sandeep,
I did that but it is not triggering the email just like before.
Thanks