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")

...

The ID of the issue's time spent field

...

menuTextHighlightColour

...

textHighlightColour

...

jiraLogoUrl

...

Atlassian User Interface's panel background color

...

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

...

#escapeHtml($value)

...

  • $value: the value with HTML that should be escaped

...

#renderVersions($versions)

...

  • $versions: the list of versions to render

...

#renderVersions($!issue.fixVersions)

...

  • $issue: the issue whose comments are to be rendered

...

  • $comments: the issue whose comments are to be rendered

...

#renderCurrentCommentIfPublic()

...

#renderServiceDeskPublicComments($issue)

...

  • $issue: the issue whose comments are to be rendered

...

#renderServiceDeskInternalComments($issue)

...

  • $issue: the issue whose comments are to be rendered

...

#renderAllComments($issue)

...

  • $issue: the issue whose comments are to be rendered

...

#renderLastComment($issue)

...

  • $issue: the issue whose last comment is to be rendered

...

#renderCurrentComment()

...

#renderComment()

...

#renderComponents($issue)

...

  • $issue: the issue whose components are to be rendered

...

#renderDateTime($dateTimeValue $pattern $timezoneId)

...

  • $dateTimeValue: the value to be formatted
  • $pattern: the pattern describing the date and time format. You can find description about formatting and patterns here
  • $timezoneId: the time zone used for formatting. You can find a list in the Supported Time Zones Appendix

...

  • $dateValue: the value to be formatted
  • $pattern: the pattern describing the date format. You can find description about formatting and patterns here
  • $timezoneId: the time zone used for formatting. You can find a list in the Supported Time Zones Appendix

...

#renderLabels($issue)

...

  • $issue: the issue whose labels are to be rendered

...

#renderList($listitems)

...

  • $listitems: the list of items to be rendered

...

#renderList($!issue.affectedVersions)

...

#renderFlatList($listitems)

...

  • $listitems: the list of items to be rendered

...

#renderProject($issue)

...

  • $issue: the issue whose project name is to be rendered

...

#renderDescription($issue)

...

  • $issue: the issue whose description is to be rendered

...

#renderEnvironment($issue)

...

  • $issue: the issue whose Environment field is to be rendered

...

#renderIssueType($issue)

...

  • $issue: the issue whose type is to be rendered

...

#renderCustomerVisibleStatus($issue)

...

  • $issue: the issue whose status is to be rendered

...

#renderStatus($issue)

...

  • $issue: the issue whose status is to be rendered

...

#renderPriority($issue)

...

  • $issue: the issue whose priority is to be rendered

...

#renderResolution($issue)

...

  • $issue: the issue whose resolution is to be rendered

...

#renderIssueConstant($issueConstant)

...

  • $issueConstant: the value of an issue system field

...

#renderIssueConstant($!issue.status)

...

#renderOriginalEstimate($issue)

...

  • $issue: the issue whose original estimate is to be rendered

...

#renderRemainingEstimate($issue)

...

  • $issue: the issue whose remaining estimate is to be rendered

...

#renderTimeSpent($issue)

...

  • $issue: the issue whose time spent is to be rendered

...

#renderSummary($issue)

...

  • $issue: the issue whose summary is to be rendered

...

#renderUser($user)

...

  • $user: the user to be rendered

...

#renderUser($!issue.assignee)

...

  • $commentObject: the comment whose body is to be rendered

...

#renderTextWithCommentRenderer($textToRender)

...

  • $textToRender: the text that should be rendered

...

#renderTextWithCommentRenderer($!worklog.comment)

...

#renderCustomField($issue $customFieldKey)

...

  • $issue: the issue whose custom field is to be rendered
  • $customFieldKey: the key of the custom field

...

#renderAllCustomFields($issue)

...

  • $issue: the issue whose custom fields are to be rendered

...

#renderWorklog($worklog)

...

  • $worklog: the worklog entry to be rendered

...

#renderWorklogs($issue)

...

  • $issue: the issue whose worklog entries are to be rendered

...

#renderUserProperty($user $propertyName)

...

  • $user: the user whose property is to be rendered
  • $propertyName: the name of the property to be rendered

...

#footer()

...

Renders the Email This Issue footer.

...

#renderLinkToCustomerPortal($issue $linkText)

...

  • $issue: the issue whose customer portal link is to be rendered
  • $linkText the text of the link

...

#renderLinkToIssueCustomerPortal($issue $linkText)

...

  • $issue: the issue whose customer portal link is to be rendered
  • $linkText the text of the link

...

#renderTemplate($templateId)

...

  • $templateId: the ID of the template to be rendered

...

#renderIssueComments($order $num $restriction)

...

  • $order: the order in which the comments should be displayed
    Possible values:
    • empty or 'asc': the comments will be ordered by their creation date, ascending
    • 'desc': the comments will be ordered by their creation date, descending
  • $num: limit the number of comments that should be rendered
    Possible values:
    • 'all': every comment will be rendered
    • any integer: maximum the indicated number of comments will be rendered
  • $restriction: comment rendering can be restricted by the comment's visibility
  • Possible values: 
    • empty or 'none': both public and internal comments will be rendered
    • 'public': only public comments will be rendered
    • 'internal': only internal comments will be rendered

...

#renderOptOutLink($linkText)

...

  • $linkText: the text of the link

...

Redirect
filename
locationhttps://docs.meta-inf.hu/email-this-issue-for-jira-server-data-center/documentation/outgoing-emails/email-templates/velocity-context-in-email-templates

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.