Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

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

...

Name

...

Type

...

Description

...

$!currentUserInfo.user: current user object
$!currentUserInfo.roles: current user's project roles
$!currentUserInfo.groups: current user's groups.

...

userPropertyManager

...

 Access to Jira user properties. .

Usage:

Refernces to user properties by property name must be prefixed with "jira.meta." due to the nature of the Jira API.

E.g. If the user has a property, called "phone", the phone property may be rendered as

$!userPropertyManager.getPropertySet(<user object>).getString("jira.meta.phone")

...

jetiFieldRenderer provides a lot of useful methods to render issue fields

...

String renderCustomField(Issue issue, String fieldKey);

...

Object renderCustomFieldAsObject(Issue issue, String fieldKey);

...

Returns the value of the custom field as Raw value.

The Raw or Object value allows for further processing or access to methods, and attribues

...

$!jetiFieldRenderer.renderCustomFieldAsObject($!issue, "customfield_10011")

E.g. render the Display name attribute of a user selected in a user picker field

$!jetiFieldRenderer.renderCustomFieldAsObject($!issue, "customfield_10011").getDisplayName()

...

String renderVersions(Collection<Version> versions);

...

String renderComponents(Collection<ProjectComponent> components);

...

String renderLabels(Collection<Label> labels);

...

String renderSecurityLevel(GenericValue securityLevel);

...

String renderIssueConstant(IssueConstant issueConstant);

...

String renderUser(User user);

...

String renderDateTime(Timestamp ts);

...

E.g.

  • $!jetiFieldRenderer.renderDateTime($!issue.getCreated())
  • render the value of a date or date time picker field: $!jetiFieldRenderer.renderDateTime($!jetiFieldRenderer.renderCustomFieldAsObject($!issue, "customfield_10011"))

...

String renderEstimate(TemplateIssue ti, I18nHelper i18n);

...

String renderRemainingEstimate(TemplateIssue ti, I18nHelper i18n);

...

String renderWorklog(TemplateIssue ti, I18nHelper i18n);

...

I18nHelper getI18nBean(String locale);

...

Returns a I18nBean for the given locale, locale string follows java syntax

...

String getLinkToCustomerPortal(Issue issue);

...

Returns an absolute link to the customer portal belonging to the service management project of the issue.

If the issue is not from a Service Management project, it returns null

...

String getLinkToIssueInCustomerPortal(Issue issue);

...

Returns an absolute link to the issue in the customer portal belonging to the service management project of the issue.

If the issue is not from a Service Management project, it returns null

...

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

It provides the below methods:

...

DateTimeFormatter getJiraDateTimeFormatter()

...

DateFormat getJavaDateFormat()

...

DateFormat getJavaDateFormat(int style)

...

DateFormat getJavaDateFormat(int style, String locale)

...

Returns a Java DateFormat object configured with the value of the style constants (see java documentation) and a locale.

...

DateFormat getJavaDateTimeFormat()

...

DateFormat getJavaDateTimeFormat(int dateStyle, int timeStyle)

...

DateFormat getJavaDateTimeFormat(int dateStyle, int timeStyle, String locale)

...

DateFormat getJavaDateTimeFormat(String pattern)

...

String formatSafely(DateFormat formatter , Date value)

...

$!jetiFieldFormatter.formatSafely($!formatter, $issue.updated)

or

$!jetiFieldFormatter.formatSafely($!formatter, $issue.getCustomFieldValue("customfield_12345"))

...

TimeZone getTimeZone(String tzID)

...

TimeZone getDefaultTimeZone()

...

String[] getAvailableTimeZoneIDs()

...

...

String encodeUrl(String url);

...

Code Block
#set($firtstIssue = $!templateSupport.firstIssueMatchingJQL("project = $issue.projectObject.key AND assignee=$!currentUser.name AND priority = Highest"))

$!firstIssue.summary

...

Code Block
#set($searchResults = $!templateSupport.searchForIssuesByJQL("project=IT AND resolution=Unresolved", 10))
  #foreach($result in $searchResults.getResults())
$velocityCount - $!result.key (comments: $!result.comments.size())
  #end

...

Code Block
#if($!templateSupport.issueMatchesJQL("mycustomfield = somevalue AND component=ImportantComponent", $!issue) 
## do something...
#end

...

Creates a Java Locale object to be used in date / number formatting or language support.

Local name is composed of language code and country code.

e.g. "fr" is for french language, while "fr_FR" is the french spoken in France.

Code Block
#set($frenchLocale = $!templateSupport.getLocale("fr_FR")

...

Create an I18nHelper object for the locale

Local name is composed of language code and country code.

e.g. "fr" is for french language, while "fr_FR" is the french spoken in France.

Code Block
#set($i18nFrench = $!templateSupport.getI18nHelper("fr_FR")	

...

Create an I18nHelper object for the locale

Local name is composed of language code and country code.

e.g. "fr" is for french language, while "fr_FR" is the french spoken in France.

Code Block
#set($frenchLocale = $!templateSupport.getLocale("fr_FR")
#set($i18nFrench = $!templateSupport.getI18nHelper($frenchLocale)	

...

Code Block
#if($!templateSupport.isAgent($!issue.reporter, $!issue.projectObject)
...
#end

...

Code Block
#set($parentValue = $!templateSupport.getParentValueFromCascadingSelectFieldValue($!issue.getCustomFieldValue("customfield_12345"))

#set($childValue = $!templateSupport.getChildValueFromCascadingSelectFieldValue($!issue.getCustomFieldValue("customfield_12345"))

customfield_12345 is the key of a cascade select field

...

Code Block
#if($!templateSupport.isInternalComment($!comment)) 
...
#end

...

Expertisefinder redirect
forcedfalse
dest{"value":"https://docs.meta-inf.hu/email-this-issue-for-jira-server-data-center/documentation/outgoing-emails/email-templates/velocity-context-in-email-templates"}
typeurl
enabledtrue

Thank you for visiting our old product documentation site. Note that we no longer store or update our documentation here.

Please navigate to our new documentation site and update your bookmarks accordingly. If you're looking for the former content of this page, click here.