Customizing email templates
Last updated
Last updated
Email templates define the content and layout of the emails that are sent using The Email Button and the Email Screen, as Email Notification Schemes or as Workflow Post Function, all of which you can configure with your custom templates. To manage templates, do the following:
1. Go to Templates under the EMAIL CONTENT menu item of the Outgoing Mails configuration tab.
2. Click on Add to create a new template or click on the three dots and choose Edit to modify an already existing template.
Templates may contain static and dynamic content related to issues, projects and users, such as:
Issue fields
Custom fields
Comments
Worklog details
It is possible to build templates from scratch, and there are predefined template themes that help to get started with custom templates.
Themes help you to build your own templates for various goals. Click the Add button to add new templates from themes.
Email Templates may be built using using Apache Velocity Markup. Aspects to consider:
Basic Settings
HTML Template
Text Template
Category: Emails are grouped into categories. Enter any text, and a category will be automatically created if doesn't already exist. There are special categories for special uses, for instance the responses. By default, templates in this category can be selected as a canned response on the Email Screen.
Subject templates are part of an Email template. They are used for generating the final subject of the emails sent using this template. The Subject template can contain static text and dynamic content, such as issue fields and custom fields.
The $!mailSubject variable is replaced by the subject you enter in the Email Notification Schemes or Workflow Post Function.
When you send a manual email, the Subject Template is used for generating the subject in the The Email Button and the Email Screen. The subject you enter in the email screen is not modified further by the email templates when the email is sent.
HTML Template is used when an HTML email is sent using this email template. The HTML body may be combined with HTML and Apache Velocity Markup to give templates a customizable look and layout.
The HTML template may be developed using a WYSIWYG editor. With this editor everyone can develop templates without HTML coding experience.
The Rich Text editor allows users to apply formatting, add tables, images, links, preview the template and edit content in full screen.
HTML can include issue fields and custom fields, and complex structures such as:
Comments
Issue link information
Change history
To edit HTML directly, open the HTML Editor and make changes to the source code of the template.
Email This Issue can embed an image targeted by a URL on an <img>
tag level. This way you can send out attachments of the issue, and the recipient does not need to connect and create a Jira user account to see the attachment.
To allow this feature, add the data-embed="true"
attribute to the <img>
element.
Example:
The Text Template is used for sending pure text emails with this email template.
The Text Body part can also contain issue fields, custom fields and the same set of complex structures as the HTML Body.
Field Picker is a dropdown list of all issue fields and custom fields. When a field is selected, a tiny popup dialog opens with the template code fragment needed to render the value of the field in the email. Click the button in the dialog to add the code to the cursor position.
The Field Picker is available for Subject Template, HTML and Text Body templates.
The following is a list of variables that are available in the email templates.
The following is the list of macros that are available in the email templates.
According to Atlassian's announcement, the 'Epic Link' custom field will be deprecated as of 31th May 2022.
As a consequence, exisiting macros utilizing the 'Epic Link' value (usually in a form of #renderCustomField($!issue 'customfield_10014'
- however, the custom field ID can vary per site) won't work after this deadline.
Please, review and consider replacing your old macros with any of our new offerings (#renderParent
or #renderParentEpic
).
Due to some known limitations in hierarchy level retrieval for custom issue types introduced in Advanced Roadmaps (verified by Atlassian in this community announcement), the #renderParent
macro currently does not work as expected for higher hierarhy levels than that of Epic (1).
E.g. #renderParent($!issue, 2)
will not render a parent having 'Initiative' issue type (hierarchy level 2).
It is possible to add certain text to a URL link in a template. Open the template in its raw HTML editor form and use the following code:
Make sure to use the correct customfield
ID as shown in the following example:
Templates offer a handful of operations under the three dots.
While developing a template it is necessary to validate the look, layout and content the template renders. For the HTML Body you can use the rich text editor's Preview function to check the layout and content, but the best way to validate whether a template is correct is using the Test operation. It allows you to enter an issue key and send yourself an HTML or Text formatted email.
Once the email was sent, verify in your email app whether the content and layout was according your expectations.
Theme
Description
All Details
This theme is used for adding templates that render all issue fields, including custom fields.
Issue Commented
This theme is useful for notifications on events that contain comments, e.g. when an issue is commented, or a transition is executed.
Issue Updated
This theme focuses on highlighting changes made to an issue.
Work Logged
This theme gathers worklog information. It is useful for notifications on worklog-related events.
Empty
An empty theme for starting a template from scratch.
Macro signature
Parameters
Description
Example
#renderDateTime($dateTimeValue $pattern $timezone)
$dateTimeValue:
the value to be formatted
$pattern
: the pattern describing the date and time format. You can find description about formatting and patterns here.
$timezone:
the time zone used for formatting. You can find a list of in the Supported Time Zones Appendix.
Formats a dateTime
field based on the pattern and the timezone.
#renderDateTime($!issue.created "dd MMM yyyy hh:mm a" "Australia/West")
#renderIssueComments($order $num $restrictions)
$order
: "asc" or "desc"
$num
: an positive integer number or "all" to render all comments matching <restrictions>
$restrictions:
comment restrictions, values are:
empty: render all comments regardless of the restrictions
"none": render comments which are not limited to groups, roles or which are not internal in Service Management
"public": render Service Management public comments
"internal": render Service Management internal comments
A generic, multi-purpose comment rendering macro.
#renderIssueComments("desc" "all" "")
prints all comments starting with the latest one.
#renderIssueComments("asc" "all" "")
prints all comments starting with the first one.
#renderIssueComments("desc" "1" "")
prints the latest comment.
#renderIssueComments("desc" "all" "none")
prints all comments which are not restricted.
#renderIssueComments("desc" "all" "public")
prints all public comments starting with the latest one.
#renderLinkToPortal($linkText)
$linkText
: text to show for the link in html mails.
Default value: "View portal"
In case of a text email this parameter is ignored, and the full URL is generated.
Renders a link to the portal with a custom text.
#renderLinkToPortal("View Customer Portal")
#renderLinkToPortalRequest($linkText)
$linkText
: text to show for the link in html mails
Default value: "View request"
In case of a text email this parameter is ignored, and the full URL is generated.
Renders a link to the request with a custom text.
#renderLinkToPortalRequest("Open request")
#renderAllComments($comments)
$comments
: The comments to render
Renders all comments (both public and internal).
#renderAllComments($!issue.comments)
#renderChanges()
Renders the changelog in a readable structure.
#renderChanges()
#renderComments($comments)
$comments
: The comments to render
Renders the public comments.
#renderComments($!issue.comments)
#renderCommentsInReverseOrder($comments)
$comments
: The comments to render
Renders the public comments in reverse order.
#renderCommentsInReverseOrder($!issue.comments)
#renderCustomField($issue $customFieldKey)
$issue
: the issue in the context
$customFieldKey
key of the custom field(eg. customfield_10001
)
Renders the value of the custom field as displayed in Jira.
#renderCustomField($!issue, 'customfield_10603')
#renderLastComment($issue)
$issue
: The issue
Renders the last comment of the issue.
#renderLastComment($!issue)
#renderParent($issue, hierarchyLevel)
$issue
: The issue, whose parent issue shall be rendered
$hierarchyLevel
: the minimal hierarchy level of the parent issue to be rendered
Renders the parent issue of the issue passed as parameter, only if the hierarchy level of the parent issue is higher than or equal to the specified hierarchy level.
Hierarchy levels of some known issue types:
sub-task: -1
task/story: 0
epic: 1
#renderParent($!issue, 0)
=> renders Story/Task or higher level (e.g. Epic) parent issue
#renderParent($!issue, 1)
=> renders Epic or higher level (e.g. Initiative) parent issue
#renderParentEpic($issue)
$issue
: The issue, whose parent issue shall be rendered
Renders the parent issue of the issue passed as parameter, only if the parent issue is an Epic.
In this regard, it can be considered as a replacement for the former 'Epic Link' custom field renderer.
#renderParentEpic($!issue)
Template operation
Definition
Test
Opens the Test Template dialog.
Copy
Opens the template editor screen with a copy of the current template.
Edit
Opens the template editor.
Delete
Deletes the template from the system
Variable
Definition
Example
Type
currentUser
The current user sending the email
$!currentUser.displayName
Renders the full name of the current user.
mailSubject
The email subject entered manually in the subject field on the manual email screen, notifications or workflow post functions. In case of a Send auto reply action this will represent the subject of the original email.
String
mailBody
The email body entered manually in the Body field in the manual email screen, notifications or workflow post functions.
Add this variable to all templates to render an email body entered by users. In case of a Send auto reply action this will represent the body of the original email.
String
issue
The Issue object with all available fields. The email is being sent in relation to this issue.
$!issue.summary
Renders the issue summary in the template.
baseUrl
The base URL of the Jira Cloud site. Useful to add links to Jira screens or operations.
It is a simple String value you can use in building links.
String
issueEvent
The issue event if the email is being sent as an event notification.
comment
The comment the user enters during the operation. E.g. when editing the issue or executing a workflow transition.
#renderComment()
Renders the comment.
changeLog
The changelog holding information about all fields changed during the operation. Old and new values are available.
#renderChanges()
Renders the changelog in a readable structure.
worklog
The worklog object holding details of the worklog entered or edited.
#renderWorklog()
Renders the worklog details.
emailCommand
The email definition object holding all recipients, the subject and body, the issue event and the comment details.
$!emailCommand.attachment
s
Returns the list of attachments being added to the email.
sentDate
A formatted date representing when the original email was processed by Email This Issue.
Available only in Reply/Reply all/Forward for an email.
$!sentDate
Prints the when the email was processed by Email This Issue.
String
stringUtils
String helper methods
$!stringUtils.isBlank($!issue.summary)
returns true if the issue summary is empty or null.
$!stringUtils.join($!issue.labels, ", ")
prints the labels separated by comma.
templateSupport
The support object useful in templates. A constantly enhanced object, that will receive more and more methods.