# Velocity Context in email templates

Email templates are velocity macro files. When email templates are used to render email body, the following Velocity context attributes are available.

## Template Context Objects <a href="#velocitycontextinemailtemplates-templatecontextobjects" id="velocitycontextinemailtemplates-templatecontextobjects"></a>

| Name                          | Type                                                                                                                                                                      | Description                                                                                                                                                                                                                                                                                                                                                                                       |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `attachmentsManager`          | [com.atlassian.jira.mail.util.MailAttachmentsManager](https://docs.atlassian.com/software/jira/docs/api/8.4.1/com/atlassian/jira/mail/util/MailAttachmentsManager.html)   | Manager component                                                                                                                                                                                                                                                                                                                                                                                 |
| `baseurl`                     | String                                                                                                                                                                    | The base url of the Jira instance, set under General Configuration.                                                                                                                                                                                                                                                                                                                               |
| `buildutils`                  | [com.atlassian.jira.util.BuildUtils](https://docs.atlassian.com/software/jira/docs/api/8.4.1/com/atlassian/jira/util/BuildUtils.html)                                     | <p><br></p>                                                                                                                                                                                                                                                                                                                                                                                       |
| `customfieldManager`          | [com.atlassian.jira.issue.CustomFieldManager](https://docs.atlassian.com/software/jira/docs/api/8.4.1/com/atlassian/jira/issue/CustomFieldManager.html)                   | Support for adding custom fields to outgoing emails                                                                                                                                                                                                                                                                                                                                               |
| `dateformatter`               | [com.atlassian.jira.web.util.OutlookDate](https://docs.atlassian.com/software/jira/docs/api/8.4.1/com/atlassian/jira/web/util/OutlookDate.html)                           | Date format support                                                                                                                                                                                                                                                                                                                                                                               |
| `issue`                       | [com.atlassian.jira.mail.TemplateIssue](https://docs.atlassian.com/software/jira/docs/api/8.4.1/com/atlassian/jira/mail/TemplateIssue.html)                               | Issue extended with support for processing in velocity templates                                                                                                                                                                                                                                                                                                                                  |
| `i18n`                        | [com.atlassian.jira.util.I18nHelper](https://docs.atlassian.com/software/jira/docs/api/8.4.1/com/atlassian/jira/util/I18nHelper.html)                                     | I18n support                                                                                                                                                                                                                                                                                                                                                                                      |
| `jirakeyutils`                | [com.atlassian.jira.util.JiraKeyUtils](https://docs.atlassian.com/software/jira/docs/api/8.4.1/com/atlassian/jira/util/JiraKeyUtils.html)                                 | <p><br></p>                                                                                                                                                                                                                                                                                                                                                                                       |
| `jirautils`                   | [com.atlassian.jira.util.JiraUtils](https://docs.atlassian.com/software/jira/docs/api/8.4.1/com/atlassian/jira/util/JiraUtils.html)                                       | <p><br></p>                                                                                                                                                                                                                                                                                                                                                                                       |
| `remoteUser`                  | [com.atlassian.jira.user.ApplicationUser](https://docs.atlassian.com/software/jira/docs/api/8.4.1/com/atlassian/jira/user/ApplicationUser.html)                           | Current user running the action or null                                                                                                                                                                                                                                                                                                                                                           |
| `rendererManager`             | [com.atlassian.jira.issue.RendererManager](https://docs.atlassian.com/software/jira/docs/api/8.4.1/com/atlassian/jira/issue/RendererManager.html)                         | <p><br></p>                                                                                                                                                                                                                                                                                                                                                                                       |
| `stringUtils`                 | [org.apache.commons.lang.StringUtils](https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html)                                   | String helper methods                                                                                                                                                                                                                                                                                                                                                                             |
| `textutils`                   | [com.opensymphony.util.TextUtils](http://bethecoder.com/open-source/open-symphony/oscore-2.2.6/com/opensymphony/util/TextUtils.java.html)                                 | Jira's text util methods                                                                                                                                                                                                                                                                                                                                                                          |
| `userutils`                   | [com.atlassian.core.user.UserUtils](https://docs.atlassian.com/software/jira/docs/api/8.4.1/com/atlassian/jira/user/UserUtils.html)                                       | <p><br></p>                                                                                                                                                                                                                                                                                                                                                                                       |
| `jetiFieldRenderer`           | See details [here](#velocitycontextinemailtemplates-jetifieldrendererjetifieldrenderer).                                                                                  | Support for field rendering in templates                                                                                                                                                                                                                                                                                                                                                          |
| `jetiFieldFormatter`          | See details [here](#velocitycontextinemailtemplates-jetifieldformatterjetifieldformatter).                                                                                | Support for date/time formatting in templates                                                                                                                                                                                                                                                                                                                                                     |
| `templateSupport`             | See details [here](#templatesupport).                                                                                                                                     | Support for email templates, rendering, formatting                                                                                                                                                                                                                                                                                                                                                |
| `number`                      | [com.atlassian.jira.util.velocity.Numbertool](https://docs.atlassian.com/software/jira/docs/api/8.4.1/com/atlassian/jira/util/velocity/NumberTool.html)                   | Support for Number formatting in templates. See the API [documentation](https://docs.atlassian.com/jira/latest/com/atlassian/jira/util/velocity/NumberTool.html)                                                                                                                                                                                                                                  |
| `currentUserInfo`             | <p><br></p>                                                                                                                                                               | <p><code>$!currentUserInfo.user</code>: current user object<br><code>$!currentUserInfo.roles</code>: current user's project roles<br><code>$!currentUserInfo.groups</code>: current user's groups.</p>                                                                                                                                                                                            |
| `userPropertyManager`         |  [com.atlassian.jira.user.UserPropertyManager](https://docs.atlassian.com/software/jira/docs/api/8.4.1/com/atlassian/jira/user/UserPropertyManager.html)                  | <p>Access to Jira user properties.</p><p>Usage:</p><p>References to user properties by property name must be prefixed with "<code>jira.meta</code>." due to the nature of the Jira API.</p><p>E.g. If the user has a property, called "phone", the phone property may be rendered as</p><p><code>$!userPropertyManager.getPropertySet(&#x3C;user object>).getString("jira.meta.phone")</code></p> |
| `currentTimestamp`            | [java.util.Date ](https://docs.oracle.com/javase/7/docs/api/java/util/Date.html)                                                                                          | Date and time of rendering the template, this like "now".                                                                                                                                                                                                                                                                                                                                         |
| `jiraDurationUtils`           | [com.atlassian.jira.util.JiraDurationUtils](https://docs.atlassian.com/software/jira/docs/api/8.4.1/com/atlassian/jira/util/JiraDurationUtils.html)                       | Util class responsible for printing durations in various formats.                                                                                                                                                                                                                                                                                                                                 |
| `diffutils`                   | [com.atlassian.jira.mail.DiffUtils](https://docs.atlassian.com/software/jira/docs/api/8.4.1/com/atlassian/jira/mail/DiffUtils.html)                                       | Compares two string values and renders wiki markup diffs.                                                                                                                                                                                                                                                                                                                                         |
| `isJIRA610OrLater`            | boolean                                                                                                                                                                   | Determines whenever the currently installed Jira version is at least 6.1.0                                                                                                                                                                                                                                                                                                                        |
| `datetimeformatter`           | [com.atlassian.jira.datetime.DateTimeFormatter](https://docs.atlassian.com/software/jira/docs/api/8.2.0/com/atlassian/jira/datetime/DateTimeFormatter.html)               | Date-time format support                                                                                                                                                                                                                                                                                                                                                                          |
| `timeSpentFieldId`            | String                                                                                                                                                                    | The ID of the issue's time spent field                                                                                                                                                                                                                                                                                                                                                            |
| `padSize`                     | Integer                                                                                                                                                                   | Default padding size for templates (20)                                                                                                                                                                                                                                                                                                                                                           |
| `lfbean`                      | [com.atlassian.jira.config.properties.LookAndFeelBean](https://docs.atlassian.com/software/jira/docs/api/8.2.0/com/atlassian/jira/config/properties/LookAndFeelBean.html) | Support for accessing Jira's look and feel parameters                                                                                                                                                                                                                                                                                                                                             |
| `menuTextHighlightColour`     | String                                                                                                                                                                    | Jira's menu text highlight color                                                                                                                                                                                                                                                                                                                                                                  |
| `textHighlightColour`         | String                                                                                                                                                                    | Jira's text highlight color                                                                                                                                                                                                                                                                                                                                                                       |
| `jiraLogoUrl`                 | String                                                                                                                                                                    | URL that points to Jira's logo image                                                                                                                                                                                                                                                                                                                                                              |
| `topBackgroundColour`         | String                                                                                                                                                                    | Jira's top bar background-color                                                                                                                                                                                                                                                                                                                                                                   |
| `topTxtColour`                | String                                                                                                                                                                    | Jira's top bar text color                                                                                                                                                                                                                                                                                                                                                                         |
| `topHighlightColor`           | String                                                                                                                                                                    | Jira's top bar highlight color                                                                                                                                                                                                                                                                                                                                                                    |
| `topTextHighlightColor`       | String                                                                                                                                                                    | Jira's top bar text highlight color                                                                                                                                                                                                                                                                                                                                                               |
| `topSeparatorBackgroundColor` | String                                                                                                                                                                    | Jira's top bar separator background-color                                                                                                                                                                                                                                                                                                                                                         |
| `menuTxtColour`               | String                                                                                                                                                                    | Jira's menu text color                                                                                                                                                                                                                                                                                                                                                                            |
| `menuBackgroundColour`        | String                                                                                                                                                                    | Jira's menu background-color                                                                                                                                                                                                                                                                                                                                                                      |
| `menuSeparatorColour`         | String                                                                                                                                                                    | Jira's menu separator color                                                                                                                                                                                                                                                                                                                                                                       |
| `textHeadingColour`           | String                                                                                                                                                                    | Jira's header text color                                                                                                                                                                                                                                                                                                                                                                          |
| `textLinkColour`              | String                                                                                                                                                                    | Jira's link text color                                                                                                                                                                                                                                                                                                                                                                            |
| `textActiveLinkColour`        | String                                                                                                                                                                    | Jira's active link text color                                                                                                                                                                                                                                                                                                                                                                     |
| `textFontFamily`              | String                                                                                                                                                                    | Jira's text font                                                                                                                                                                                                                                                                                                                                                                                  |
| `textSize`                    | String                                                                                                                                                                    | Jira's text size                                                                                                                                                                                                                                                                                                                                                                                  |
| `textColour`                  | String                                                                                                                                                                    | Jira's text color                                                                                                                                                                                                                                                                                                                                                                                 |
| `textSubtleColour`            | String                                                                                                                                                                    | Jira's subtle text color                                                                                                                                                                                                                                                                                                                                                                          |
| `borderColour`                | String                                                                                                                                                                    | Jira's border color                                                                                                                                                                                                                                                                                                                                                                               |
| `auiPanelBackgroundColour`    | String                                                                                                                                                                    | Atlassian User Interface's panel background color                                                                                                                                                                                                                                                                                                                                                 |
| `auiPanelBorderColour`        | String                                                                                                                                                                    | Atlassian User Interface's panel border color                                                                                                                                                                                                                                                                                                                                                     |
| `auiInfoBackgroundColour`     | String                                                                                                                                                                    | Atlassian User Interface's info panel background color                                                                                                                                                                                                                                                                                                                                            |
| `auiInfoBorderColour`         | String                                                                                                                                                                    | Atlassian User Interface's info panel border color                                                                                                                                                                                                                                                                                                                                                |
| `auiSuccessBackgroundColour`  | String                                                                                                                                                                    | Atlassian User Interface's success panel background color                                                                                                                                                                                                                                                                                                                                         |
| `auiSuccessBorderColour`      | String                                                                                                                                                                    | Atlassian User Interface's success panel border color                                                                                                                                                                                                                                                                                                                                             |
| `auiErrorBackgroundColour`    | String                                                                                                                                                                    | Atlassian User Interface's error panel background color                                                                                                                                                                                                                                                                                                                                           |
| `auiErrorBorderColour`        | String                                                                                                                                                                    | Atlassian User Interface's error panel border color                                                                                                                                                                                                                                                                                                                                               |
| `auiWarningBackgroundColour`  | String                                                                                                                                                                    | Atlassian User Interface's warning panel background color                                                                                                                                                                                                                                                                                                                                         |
| `auiWarningBorderColour`      | String                                                                                                                                                                    | Atlassian User Interface's warning panel border color                                                                                                                                                                                                                                                                                                                                             |
| `linkstyle`                   | String                                                                                                                                                                    | Comment author link style                                                                                                                                                                                                                                                                                                                                                                         |
| `commentBackgroundl`          | String                                                                                                                                                                    | Comment quotes color                                                                                                                                                                                                                                                                                                                                                                              |

## jetiFieldRenderer <a href="#velocitycontextinemailtemplates-jetifieldrendererjetifieldrenderer" id="velocitycontextinemailtemplates-jetifieldrendererjetifieldrenderer"></a>

`jetiFieldRenderer` provides the following methods to render issue fields:

| Method                                                               | Description                                                                                                                                                                                                | Usage                                                                                                                                                                                                                                                                                                  |
| -------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `String renderCustomField(Issue issue, String fieldKey);`            | Renders a custom field value as a string value                                                                                                                                                             | `$!jetiFieldRenderer.renderCustomField($!issue, "customfield_10011")`                                                                                                                                                                                                                                  |
| `Object renderCustomFieldAsObject(Issue issue, String fieldKey);`    | <p>Returns the value of the custom field as Raw value.</p><p>The Raw or Object value allows for further processing or access to methods, and attributes</p>                                                | <p><code>$!jetiFieldRenderer.renderCustomFieldAsObject($!issue, "customfield_10011")</code></p><p>E.g. render the Display name attribute of a user selected in a user picker field</p><p><code>$!jetiFieldRenderer.renderCustomFieldAsObject($!issue, "customfield_10011").getDisplayName()</code></p> |
| String `renderVersions(Collection<Version> versions);`               | Renders the given versions as a comma-separated list of version names.                                                                                                                                     | E.g. `$!jetiFieldRenderer.renderVersions($!issue.getFixVersions())`                                                                                                                                                                                                                                    |
| `String renderComponents(Collection<ProjectComponent> components);`  | Renders the given components as a comma-separated list of component names.                                                                                                                                 | E.g. `$!jetiFieldRenderer.renderComponents($!issue.getComponents()`)                                                                                                                                                                                                                                   |
| `String renderLabels(Collection<Label> labels);`                     | Renders the given labels as a comma-separated list of label names.                                                                                                                                         | E.g. `$!jetiFieldRenderer.renderLabels($!issue.getLabels())`                                                                                                                                                                                                                                           |
| `String renderSecurityLevel(GenericValue securityLevel);`            | Renders the name of the given Security Level object                                                                                                                                                        |  `$!jetiFieldRenderer.renderSecurityLevel($!issue.getSecurityLevel())`                                                                                                                                                                                                                                 |
| String re`nderIssueConstant(IssueConstant issueConstant);`           | Renders the name of an Issue type, Resolution, Priority or Status                                                                                                                                          | `$!jetiFieldRenderer.renderIssueConstant($!issue.getPriority())`                                                                                                                                                                                                                                       |
| `String renderUser(User user);`                                      | Renders the DisplayName attribute of a User or Application User object safely, if null, returns empty string                                                                                               | `$!jetiFieldRenderer.renderUser($!issue.getAssignee())`                                                                                                                                                                                                                                                |
| `String renderDateTime(Timestamp ts);`                               | Renders a Timestamp object using Jira's default date format, `DateTimeFormat.format(`)                                                                                                                     | <p>E.g.</p><ul><li><code>$!jetiFieldRenderer.renderDateTime($!issue.getCreated())</code></li><li>render the value of a date or date time picker field: <code>$!jetiFieldRenderer.renderDateTime($!jetiFieldRenderer.renderCustomFieldAsObject($!issue, "customfield_10011"))</code></li></ul>          |
| `String renderEstimate(TemplateIssue ti, I18nHelper i18n);`          | Renders the issue's Original estimate in nicely readable format, like 3d 4h 5m                                                                                                                             | `$!jetiFieldRenderer.renderEstimate($!issue, $i18n)`                                                                                                                                                                                                                                                   |
| `String renderRemainingEstimate(TemplateIssue ti, I18nHelper i18n);` | Renders the issue's Remaining estimate in nicely readable format, like 3d 4h 5m                                                                                                                            | `$!jetiFieldRenderer.renderOriginalEstimate($!issue, $i18n)`                                                                                                                                                                                                                                           |
| `String renderWorklog(TemplateIssue ti, I18nHelper i18n);`           | Renders the issue's Logged Work Time in nicely readable format, like 3d 4h 5m                                                                                                                              | `$!jetiFieldRenderer.renderWorklog($!issue, $i18n)`                                                                                                                                                                                                                                                    |
| `I18nHelper getI18nBean(String locale);`                             | Returns a I18nBean for the given locale, locale string follows[ java syntax](https://docs.oracle.com/javase/7/docs/api/java/util/Locale.html)                                                              | E.g. get the language resources for French: `$!jetiFieldRenderer.getI18nBean("fr")`                                                                                                                                                                                                                    |
| `String getLinkToCustomerPortal(Issue issue);`                       | <p>Returns an absolute link to the customer portal belonging to the service management project of the issue.</p><p>If the issue is not from a Service Management project, it returns null</p>              | `$!jetiFieldRenderer.getLinkToCustomerPortal($!issue)`                                                                                                                                                                                                                                                 |
| `String getLinkToIssueInCustomerPortal(Issue issue);`                | <p>Returns an absolute link to the issue in the customer portal belonging to the service management project of the issue.</p><p>If the issue is not from a Service Management project, it returns null</p> | <p><code>$!jetiFieldRenderer.getLinkToIssueInCustomerPortal</code><br><code>($!issue)</code></p>                                                                                                                                                                                                       |

&#x20;

## jetiFieldFormatter <a href="#velocitycontextinemailtemplates-jetifieldformatterjetifieldformatter" id="velocitycontextinemailtemplates-jetifieldformatterjetifieldformatter"></a>

`jetiFieldFormatter` is an object in the template context that may be used to format date or date time values.

It provides the following methods:

| Method                                                                        | Description                                                                                                                                                                                                                                                                                                            | Usage                                                                                                                                                                                |
| ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| DateTimeFormatter getJiraDateTimeFormatter()                                  | Returns a native Jira [DateTimeFormatter](https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/datetime/DateTimeFormatter.html) object                                                                                                                                                           | #set ($formatter = $jetiFieldFormatter.getJiraDateTimeFormatter())                                                                                                                   |
| DateTimeFormatter getJiraDateTimeFormatter(String style)                      | Returns a native Jira [DateTimeFormatter](https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/datetime/DateTimeFormatter.html) object configured with [DateTimeStyle](https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/datetime/DateTimeStyle.html) provided          | #set ($formatter = $jetiFieldFormatter.getJiraDateTimeFormatter("COMPLETE"))                                                                                                         |
| DateFormat getJavaDateFormat()                                                | Returns a Java [DateFormat](https://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html) object for date formatting                                                                                                                                                                                            | #set ($formatter = $jetiFieldFormatter.getJavaDateFormat())                                                                                                                          |
| DateFormat getJavaDateFormat(int style)                                       | Returns a Java [DateFormat](https://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html) object configured with the value of the style constants (see java [documentation](https://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html#getDateInstance\(int\)))                                        |                                                                                                                                                                                      |
| DateFormat getJavaDateFormat(int style, String locale)                        | Returns a Java [DateFormat](https://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html) object configured with the value of the style constants (see java [documentation](https://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html#getDateInstance\(int\))) and a locale.                          | Example for locales: en, en\_US, fr, de, see more examples in the [documentation](https://docs.oracle.com/javase/7/docs/api/java/util/Locale.html)                                   |
| DateFormat getJavaDateTimeFormat()                                            | Returns a Java [DateFormat](https://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html) object for date time formatting                                                                                                                                                                                       |                                                                                                                                                                                      |
| DateFormat getJavaDateTimeFormat(int dateStyle, int timeStyle)                | Returns a Java [DateFormat](https://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html) object for date time formatting configured with the value of the style constants (see java [documentation](https://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html#getDateInstance\(int\)))               |                                                                                                                                                                                      |
| DateFormat getJavaDateTimeFormat(int dateStyle, int timeStyle, String locale) | Returns a Java [DateFormat](https://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html) object for date time formatting configured with the value of the style constants (see java [documentation](https://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html#getDateInstance\(int\))) and a locale. |                                                                                                                                                                                      |
| DateFormat getJavaDateTimeFormat(String pattern)                              | Returns a Java [SimpleDateFormat](https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html) object for date time formatting configured with a pattern                                                                                                                                                 | #set($formatter = $jetiFieldFormatter.getJavaDateTimeFormat("dd/MM/yyyy HH:mm"))                                                                                                     |
| String formatSafely(DateFormat formatter, Date value)                         | Formats a date value using the formatter created using either of the above methods                                                                                                                                                                                                                                     | <p>$!jetiFieldFormatter.formatSafely($!formatter, $issue.updated)</p><p>or</p><p>$!jetiFieldFormatter.formatSafely($!formatter, $issue.getCustomFieldValue("customfield_12345"))</p> |
| TimeZone getTimeZone(String tzID)                                             | Returns the [TimeZone](https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html) matching the id. TimeZone can be set in the Java date time formatters created above                                                                                                                                          | $!formatter.setTimeZone($jetiFieldFormatter.getTimeZone("America/Los\_Angeles"))                                                                                                     |
| TimeZone getDefaultTimeZone()                                                 | Returns the default [TimeZone](https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html) in Jira.                                                                                                                                                                                                             |                                                                                                                                                                                      |
| String\[] getAvailableTimeZoneIDs()                                           | Returns all time zone IDs available in Jira.                                                                                                                                                                                                                                                                           |                                                                                                                                                                                      |

* [DateTimeFormatter ](https://docs.atlassian.com/software/jira/docs/api/latest/com/atlassian/jira/datetime/DateTimeFormatter.html)is part of the Jira API
* [DateFormat ](http://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html)is a standard way to format dates in Java

## templateSupport

| Method                                                                                                                                                                                               | Description                                                                                                                                                                                                                                               | Usage                                                                                                                                                                                                                                                                                                                                                   |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| String `encodeUrl(String url);`                                                                                                                                                                      | Calls [URLEncoder.encode(url)](https://docs.oracle.com/javase/7/docs/api/java/net/URLEncoder.html) to encode rendered URLs in email templates using UTF-8 encoding                                                                                        | $!templateSupport.encodeUrl($urlVariable)                                                                                                                                                                                                                                                                                                               |
| String `encodeUrl(String url, String encoding);`                                                                                                                                                     | Calls [URLEncoder.encode(url, encoding)](https://docs.oracle.com/javase/7/docs/api/java/net/URLEncoder.html) to encode rendered URLs in email templates using the encoding specified                                                                      | $!templateSupport.encodeUrl($urlVariable, \<desired encoding>)                                                                                                                                                                                                                                                                                          |
| boolean `issueMatchesJQL(String jqlQuery, Issue issue);`                                                                                                                                             | Checks if the given issue matches the JQL query                                                                                                                                                                                                           | <p>#if($!templateSupport.issueMatchesJQL("mycustomfield = somevalue AND component=ImportantComponent", $!issue)</p><p>## do something...</p><p>#end</p>                                                                                                                                                                                                 |
| I18nHelper `getI18nHelper(String localeName);`                                                                                                                                                       | <p>Create an I18nHelper object for the locale</p><p>Local name is composed of language code and country code.</p><p>e.g. "fr" is for french language, while "fr_FR" is the french spoken in France.</p>                                                   | #set($i18nFrench = $!templateSupport.getI18nHelper("fr\_FR")                                                                                                                                                                                                                                                                                            |
| I18nHelper `getI18nHelper(Locale locale);`                                                                                                                                                           | <p>Create an I18nHelper object for the locale</p><p>Local name is composed of language code and country code.</p><p>e.g. "fr" is for french language, while "fr_FR" is the french spoken in France.</p>                                                   | <p>#set($frenchLocale = $!templateSupport.getLocale("fr_FR")</p><p>#set($i18nFrench = $!templateSupport.getI18nHelper($frenchLocale)           </p>                                                                                                                                                                                                     |
| Locale `getLocale(String localeName);`                                                                                                                                                               | <p>Creates a Java Locale object to be used in date / number formatting or language support.</p><p>Local name is composed of language code and country code.</p><p>e.g. "fr" is for the French language, while "fr_FR" is the French spoken in France.</p> | #set($frenchLocale = $!templateSupport.getLocale("fr\_FR")                                                                                                                                                                                                                                                                                              |
| boolean `isAgent(ApplicationUser applicationUser, Project project);`                                                                                                                                 | Determines if the given use is an Service Management Agent in the given project.                                                                                                                                                                          | <p>#if($!templateSupport.isAgent($!issue.reporter, $!issue.projectObject)</p><p>...</p><p>#end</p>                                                                                                                                                                                                                                                      |
| boolean `isInternalComment(Comment comment);`                                                                                                                                                        | Determines if the give comment is an Service Management Internal comment in the current issue.                                                                                                                                                            | <p>#if($!templateSupport.isInternalComment($!comment))</p><p>...</p><p>#end</p>                                                                                                                                                                                                                                                                         |
| TemplateIssueSearchResults `searchForIssuesByJQL(String jql);`                                                                                                                                       | Returns a list of issues matching the given JQL query.                                                                                                                                                                                                    | <p>#set($searchResults = $!templateSupport.searchForIssuesByJQL("project=IT AND resolution=Unresolved", 10))</p><p>  #foreach($result in $searchResults.getResults())</p><p>$velocityCount - $!result.key (comments: $!result.comments.size())</p><p>  #end</p>                                                                                         |
| String `getCustomerVisibleStatus(Issue issue);`                                                                                                                                                      | Returns the Customer Visible Status name of the issue in a Service Management project.                                                                                                                                                                    | #set($!customerVisibleStatus = $!templateSupport.getCustomerVisibleStatus($!issue)                                                                                                                                                                                                                                                                      |
| Issue `firstIssueMatchingJQL(String jql);`                                                                                                                                                           | Returns the first issue that matches the given JQL query.                                                                                                                                                                                                 | <p>#set($firtstIssue = $!templateSupport.firstIssueMatchingJQL("project = $issue.projectObject.key AND assignee=$!currentUser.name AND priority = Highest"))</p><p> </p><p>$!firstIssue.summary</p>                                                                                                                                                     |
| <p>String <code>getParentValueFromCascadingSelectFieldValue(Map cascadeSelectFieldValue);</code><br><code>String getChildValueFromCascadingSelectFieldValue(Map cascadeSelectFieldValue);</code></p> | Returns the parent or child value of a Cascade Select custom field.                                                                                                                                                                                       | <p>#set($parentValue = $!templateSupport.getParentValueFromCascadingSelectFieldValue($!issue.getCustomFieldValue("customfield_12345"))</p><p> </p><p>#set($childValue = $!templateSupport.getChildValueFromCascadingSelectFieldValue($!issue.getCustomFieldValue("customfield_12345"))</p><p>customfield_12345 is the key of a cascade select field</p> |
| `String getCurrentUsersTimeZoneId()`                                                                                                                                                                 | Returns the time zone id set in the current user’s profile.                                                                                                                                                                                               | <p>The issue was updated at <code>#renderDateTime($!issue.updated "yyyy-MM-dd'T'HH:mmZ</code>'['z']'" $!templateSupport.currentUsersTimeZoneId)<br>Please note that the capital letter T in the above code is just a placeholder, an example to mark that after the date, the time value comes next.</p>                                                |
| `TemplateIssueSearchResults searchForIssuesByJQL(String jql, int maxresults);`                                                                                                                       | Same as above, but limits the results to the given number of issues.                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                         |

&#x20;

## Template macros <a href="#velocitycontextinemailtemplates-templatemacrostemplatemacros" id="velocitycontextinemailtemplates-templatemacrostemplatemacros"></a>

| Macro signature                                      | Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | Description                                                                | Example                                                                 |
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| #escapeHtml($value)                                  | <ul><li>$value: the value with HTML that should be escaped</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | Escapes the HTML in a given value, therefore it will be displayed as text. | #escapeHtml("\<p>Sample html\</p>")                                     |
| #renderVersions($versions)                           | <ul><li>$versions: the list of versions to render</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | Renders the versions.                                                      | #renderVersions($!issue.fixVersions)                                    |
| #renderComments($issue)                              | <ul><li>$issue: the issue whose comments are to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | Renders the public comments of the issue.                                  | #renderComments($!issue)                                                |
| #renderCommentsInReverseOrder($issue)                | <ul><li>$comments: the issue whose comments are to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Renders the public comments os the issue in reverse order.                 | #renderCommentsInReverseOrder($!issue)                                  |
| #renderCurrentCommentIfPublic()                      | <p><br></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | Renders the current comment if it is public.                               | #renderCurrentCommentIfPublic()                                         |
| #renderServiceDeskPublicComments($issue)             | <ul><li>$issue: the issue whose comments are to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | Renders the public comments of the issue.                                  | #renderServiceDeskPublicComments($!issue)                               |
| #renderServiceDeskInternalComments($issue)           | <ul><li>$issue: the issue whose comments are to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | Renders the internal comments of the issue.                                | #renderServiceDeskInternalComments($!issue)                             |
| #renderAllComments($issue)                           | <ul><li>$issue: the issue whose comments are to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | Renders both public and internal comments of the issue.                    | #renderAllComments($!issue)                                             |
| #renderLastComment($issue)                           | <ul><li>$issue: the issue whose last comment is to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Renders the last comment of the issue.                                     | #renderLastComment($!issue)                                             |
| #renderCurrentComment()                              | <p><br></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | Renders the current comment.                                               | #renderCurrentComment()                                                 |
| #renderComment()                                     | <p><br></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | Renders the current comment.                                               | #renderComment()                                                        |
| #renderComponents($issue)                            | <ul><li>$issue: the issue whose components are to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | Renders the components of the issue.                                       | #renderComponents($!issue)                                              |
| #renderDateTime($dateTimeValue $pattern $timezoneId) | <ul><li>$dateTimeValue: the value to be formatted</li><li>$pattern: the pattern describing the date and time format. You can find description about formatting and patterns <a href="https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html">here</a></li><li>$timezoneId: the time zone used for formatting. You can find a list in the <a href="https://docs.meta-inf.hu/email-this-issue/general/email-this-issue-for-jira-cloud-appendix/email-this-issue-for-jira-cloud-supported-time-zones">Supported Time Zones</a> Appendix</li></ul>                                                                                                                                                                                                                                                                                            | Formats a date-time field based on the pattern and the timezone.           | #renderDateTime($!issue.created "dd MMM yyyy hh:mm a" "Australia/West") |
| #renderDate($dateValue $pattern $timezoneId)         | <ul><li>$dateValue: the value to be formatted</li><li>$pattern: the pattern describing the date format. You can find description about formatting and patterns <a href="https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html">here</a></li><li>$timezoneId: the time zone used for formatting. You can find a list in the<a href="https://docs.meta-inf.hu/email-this-issue/general/email-this-issue-for-jira-cloud-appendix/email-this-issue-for-jira-cloud-supported-time-zones"> Supported Time Zones</a> Appendix</li></ul>                                                                                                                                                                                                                                                                                                         | Formats a date field based on the pattern and the timezone.                | #renderDate($!issue.created "dd MMM yyyy" "Australia/West")             |
| #renderLabels($issue)                                | <ul><li>$issue: the issue whose labels are to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | Renders the labels of the issue.                                           | #renderLabels($!issue)                                                  |
| #renderList($listitems)                              | <ul><li>$listitems: the list of items to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | Renders the items into a bullet list.                                      | #renderList($!issue.affectedVersions)                                   |
| #renderFlatList($listitems)                          | <ul><li>$listitems: the list of items to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | Renders the items into a comma-separated list.                             | #renderFlatList($!issue.affectedVersions)                               |
| #renderProject($issue)                               | <ul><li>$issue: the issue whose project name is to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Renders the project name of the issue.                                     | #renderProject($!issue)                                                 |
| #renderDescription($issue)                           | <ul><li>$issue: the issue whose description is to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | Renders the description of the issue.                                      | #renderDescription($!issue)                                             |
| #renderEnvironment($issue)                           | <ul><li>$issue: the issue whose Environment field is to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | Renders the value of the Environment field from the issue.                 | #renderEnvironment($!issue)                                             |
| #renderIssueType($issue)                             | <ul><li>$issue: the issue whose type is to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | Renders the type of the issue.                                             | #renderIssueType($!issue)                                               |
| #renderCustomerVisibleStatus($issue)                 | <ul><li>$issue: the issue whose status is to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | Renders the status of the issue that is visible to the customer.           | #renderCustomerVisibleStatus($!issue)                                   |
| #renderStatus($issue)                                | <ul><li>$issue: the issue whose status is to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | Renders the status of the issue.                                           | #renderStatus($!issue)                                                  |
| #renderPriority($issue)                              | <ul><li>$issue: the issue whose priority is to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | Renders the priority of the issue.                                         | #renderPriority($!issue)                                                |
| #renderResolution($issue)                            | <ul><li>$issue: the issue whose resolution is to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | Renders the resolution of the issue.                                       | #renderResolution($!issue)                                              |
| #renderIssueConstant($issueConstant)                 | <ul><li>$issueConstant: the value of an issue system field</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | Renders the value of the issue system field.                               | #renderIssueConstant($!issue.status)                                    |
| #renderOriginalEstimate($issue)                      | <ul><li>$issue: the issue whose original estimate is to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | Renders the original estimate of the issue.                                | #renderOriginalEstimate($!issue)                                        |
| #renderRemainingEstimate($issue)                     | <ul><li>$issue: the issue whose remaining estimate is to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | Renders the remaining estimate of the issue.                               | #renderOriginalEstimate($!issue)                                        |
| #renderTimeSpent($issue)                             | <ul><li>$issue: the issue whose time spent is to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | Renders the time spent field value.                                        | #renderOriginalEstimate($!issue)                                        |
| #renderSummary($issue)                               | <ul><li>$issue: the issue whose summary is to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | Renders the summary of the issue.                                          | #renderSummary($!issue)                                                 |
| #renderUser($user)                                   | <ul><li>$user: the user to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | Renders the user.                                                          | #renderUser($!issue.assignee)                                           |
| #renderCommentBody($commentObject)                   | <ul><li>$commentObject: the comment whose body is to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | Renders the body of a comment.                                             | #renderCommentBody($!comment)                                           |
| #renderTextWithCommentRenderer($textToRender)        | <ul><li>$textToRender: the text that should be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | Renders the given text with the comment renderer.                          | #renderTextWithCommentRenderer($!worklog.comment)                       |
| #renderCustomField($issue $customFieldKey)           | <ul><li>$issue: the issue whose custom field is to be rendered</li><li>$customFieldKey: the key of the custom field</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | Renders the value of a custom field.                                       | #renderCustomField($!issue "customfield\_10006")                        |
| #renderAllCustomFields($issue)                       | <ul><li>$issue: the issue whose custom fields are to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | Renders the value of all custom fields on an issue.                        | #renderAllCustomFields($!issue)                                         |
| #renderWorklog($worklog)                             | <ul><li>$worklog: the worklog entry to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | Renders a worklog entry.                                                   | #renderWorklog($!issue.worklogs.get(0))                                 |
| #renderWorklogs($issue)                              | <ul><li>$issue: the issue whose worklog entries are to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | Renders all worklog entries of an issue.                                   | #renderWorklogs($!issue)                                                |
| #renderUserProperty($user $propertyName)             | <ul><li>$user: the user whose property is to be rendered</li><li>$propertyName: the name of the property to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | Renders one of the user's property.                                        | #renderUserProperty($!issue.assignee "phone")                           |
| #footer()                                            | <p><br></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | Renders the Email This Issue footer.                                       | #footer()                                                               |
| #renderLinkToCustomerPortal($issue $linkText)        | <ul><li>$issue: the issue whose customer portal link is to be rendered</li><li>$linkText the text of the link</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | Renders a link to the main page of the issue's customer portal.            | #renderLinkToCustomerPortal($!issue "Customer Portal")                  |
| #renderLinkToIssueCustomerPortal($issue $linkText)   | <ul><li>$issue: the issue whose customer portal link is to be rendered</li><li>$linkText the text of the link</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | Renders a link that points to the issue in its customer portal.            | #renderLinkToIssueCustomerPortal($!issue "Customer Portal")             |
| #renderTemplate($templateId)                         | <ul><li>$templateId: the ID of the template to be rendered</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | Renders a template.                                                        | #renderTemplate(1)                                                      |
| #renderIssueComments($order $num $restriction)       | <ul><li><p>$order: the order in which the comments should be displayed<br>Possible values:</p><ul><li>empty or 'asc': the comments will be ordered by their creation date, ascending</li><li>'desc': the comments will be ordered by their creation date, descending</li></ul></li><li><p>$num: limit the number of comments that should be rendered<br>Possible values:</p><ul><li>'all': every comment will be rendered</li><li>any integer: maximum the indicated number of comments will be rendered</li></ul></li><li>$restriction: comment rendering can be restricted by the comment's visibility</li><li><p>Possible values: </p><ul><li>empty or 'none': both public and internal comments will be rendered</li><li>'public': only public comments will be rendered</li><li>'internal': only internal comments will be rendered</li></ul></li></ul> | Renders the comments of an issue.                                          | #renderIssueComments("desc" 10 "all")                                   |
| #renderOptOutLink($linkText)                         | <ul><li>$linkText: the text of the link</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | Renders a link that customers can use to unsubscribe from notifications.   | #renderOptOutLink("Unsubscribe")                                        |

### Assets related macros

| #renderAssetsCustomField($issue $customFieldKe | <ul><li>$issue: the issue whose custom field is to be rendered</li></ul><ul><li>$customFieldKey: the key of the custom field</li></ul>                                                                                                                                                                                                                                                                                                                                               | Renders all assets objects in the field with their labels and all of their attributes. The type of the field must be Assets Object. Please note that all attributes (not visible, hidden, etc.) will be included in the email. | #renderAssetsCustomField($!issue "customfield\_10006")                                                                                                                                                    |
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| #renderAssets($aql $attributes $limit)         | <p>​</p><ul><li>$aql: search query in <a href="https://confluence.atlassian.com/servicemanagementserver/advanced-searching-aql-assets-query-language-1044784588.html">Assets Query Language</a>​</li></ul><ul><li>$attributes: <em>Optional</em> the attributes to display (used the same way as in the <code>#renderAssetsCustomField</code> macro).</li></ul><ul><li>$limit: <em>Optional</em> the maximum number of Assets Objects to display. Default: 10 Maximum: 100</li></ul> | Renders the labels and attributes of Assets Objects returned by the given AQL query.                                                                                                                                           | Render assets with the default limit and all attributes: `#renderAssets('objectId IN (1, 2, 3)')` Render assets with custom limit and all attributes: `#renderAssets('objectId IN (1, 2, 3)', $null, 25)` |
| #renderAssetsLabel($aql $limit)                | <p>​</p><ul><li>$aql: search query in <a href="https://confluence.atlassian.com/servicemanagementserver/advanced-searching-aql-assets-query-language-1044784588.html">Assets Query Language</a>​</li></ul><ul><li>$limit: <em>Optional</em> the maximum number of Assets object to display. Default: 10 Maximum: 100</li></ul>                                                                                                                                                       | Renders the labels of Assets Objects returned by the given AQL query.                                                                                                                                                          | `#renderAssetsLabel('objectId IN (1, 2, 3)', 5)`                                                                                                                                                          |

It is possible to render only the object names from an Assets field by using the `#renderCustomField($issue $customFieldKey)` macro.
