Email Template Not Rendering When Notification Body Is Filled
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 08:31 AM
Hi everyone,
I'm working with email notifications in ServiceNow and have run into a behavior I can't find documented anywhere.
I have a notification on the sysapproval_approver table that uses a shared email template (also based on the same table). However, when I include content in the "What it will contain" (Message HTML) field of the notification, the attached email template does not render at all — even if I try to include ${email.template} or ${mail_script:...} in the body.
If I clear the message body, the template renders correctly. But I need to include a custom message in the notification body and still use the shared template (which is used in multiple other notifications).
I’ve tried:
- Using ${email.template} in the body — doesn’t work.
- Calling a mail script that renders the template — doesn’t work.
- Confirmed that the template and notification are on the same table.
- Confirmed that the mail script works when used directly in a template.
Is this a known limitation? Has anyone found a workaround that allows combining a custom message in the notification body and rendering a shared template?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 11:01 AM
Hi @Abhilasha G T
When you use "${mail_script:...}" it's mean that a email script logic is running in back-end
like:
The logical name is: "user_active_check" in the notification you will pass "${mail_script:user_active_check}"
(function() {
var user = current.assigned_to;
if (!user.nil()) {
var grUser = new GlideRecord('sys_user');
if (grUser.get(user.sys_id)) {
if (grUser.active == true) {
template.print("The user is **active**.");
} else {
template.print("The user is **inactive**.");
}
} else {
template.print("User not found.");
}
} else {
template.print("No user assigned.");
}
})();
When you use "${email.template}" this need to be name of field that you need to bring the information like "${u_user_active}"
Could you share you logic in email Script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 12:29 PM - edited 07-10-2025 12:37 PM
Are you using ${email_template:name} correctly? It has the same structure as ${mail_script}. In your description you include the ":..." in your reference to using ${mail_script:...} but not in your reference to using ${email.template} which should use an underscore and not a period as well as include the template name.
Based on the information provided you should not be using the template field of the notification and instead just use the ${email_template:email_template_name} method where you want the content of the template to appear within the message body of your notification.
For example if I have an email template called "Request Details" and I want to use it the way you are. I would create the body of the email and where you want the content included in the "Request Details" template to appear in the body of the email you would use ${email_template:Request_Details}.
Edit: It also should be noted that if you use the template field of notification configuration it will only populate Subject and Body if those are empty. As soon as you manually fill in those values in the notification configuration the manual values will override the template. This is why the template works when you leave the message HTML empty but doesn't appear to work when you include any content in it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 05:27 PM
Put your custom message inside the shared template
Modify the template to include a dynamic placeholder like ${custom_message}.
Then, in each notification, add your custom text as a notification variable or even as part of a mail script that sets template.print('custom_message', '...');.
2. Use a Mail Script in the template itself
In the shared template, you can have:
<p>${mail_script:custom_intro}</p>
Then, in your notification, create a mail script named custom_intro with the custom text you want for that notification.
Different notifications can have different custom_intro mail scripts, allowing reuse of the same template.