- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 11-12-2021 10:31 PM
I have many times struggled with creating nice maintainable email templates in ServiceNow. To be able to abstract the content of an email from the logic of when to trigger, seems very complex and the best way to do it OOB is to have a lot of email scripts. But writing html in an email script is not very nice and it often becomes very specific or to general.
Having reusable templates that are easy to maintain is why I have created the Email+ Application.
What is it?
Email+ is a way to define reusable templates and components to be used in the OOB email notifications in ServiceNow. By putting everything in to a reusable template, the cost of maintenance will go down and the ease to change small things in a header across the company will rise.
Further more, Email+ also has:
- A feature to incorporate an email tracking pixel in to the email body, to track if an email has been opened.
- A feature to wrap the links in an email with a trackable link, so you can track the click rate of an email.
Where to get it?
You can get it by forking and importing it from my github repository (https://github.com/Goegler/email_plus) in to your own instance, or you can get an update set from this share project https://developer.servicenow.com/connect.do#!/share/contents/7026778_email.
Please help me improve this by reporting any issues or enhancements you may find.
How to use it?
- Open the template table (custom table included in the scoped app)
- Create a new
- Fill name and how you want the template to look like. The templates supports using Mustache templates and including other templates from the table by using the tag <email_plus_include name"internalnameoftemplate" />
- Here you can se an example of a template.
- Finally you use the list collector to select which Notifications the template should be used in.
Be aware that the notifications you select will have their "Message HTML" overwritten with the following line: ${mail_script:email_plus}.
Using Mustache templating language
When you use the mustache templating language, there are som syntax you will have to get used to. You can read all about that here.
When using it, you will have access to the "current" variable to be able to use. The "current" variable represent the GlideRecord of the record triggering the notification. So it will be the same as in an email script.
Using Email+ specific tags
There are 3 xml tags very specific to Email+.
email_plus_include
Use this to include the content of another template.
<!-- example of including another template -->
<email_plus_include name="example_header" />
the name parameter needs to be the value of the internal name of the template you want to include.
email_plus_link
Use this to include an anchor tag with a trackable link. The generation logic will replace this tag with a normal anchor tag with a trackable link using the href provided.
<!-- example of a trackable link -->
<email_plus_link href="/incident.do?sys_id={{current.sys_id}}">Go to incident</email_plus_link>
email_plus_tracker
If this is inlcuded in a template, it will be replace with a tag that makes sure to track when the email is being opened.
<!-- example of using email tracker -->
<email_plus_tracker />
How to track emails
You can track
- Open rate of emails grouped by notifications (sys_email_action).
- Clicks on specific links in the email grouped by notifications (sys_email_action).
for this, you need to use the email_plus_link tags
For each metric, there are dimensions, like device and os.
All tracking data can be found in the table "Email+ Metric Instance". There are two types of records, divided by the property Metric Type (Metric or Dimension). Below you can find a description of the properties of the two types of records.
Metric
- Has a metric type.
- Has a reference to the notification (sys_email_action) that was used to generate the email, that caused this metric.
- Has an optional value.
- Does not have a parent metric.
Dimension
- Has a parent metric.
- Has a dimension type.
- Has a value.
- Does not have a direct reference to the notification, but implicit through its parent metric.
Examples of reports using the metrics
- 1,288 Views