Wiki
Clone wikiemail-pf / Email Template Context
This pages lists and describes objects available when rendering email template.
Workflow transition context
Since the email template is rendered during execution of a workflow post-function it has access to values set in this transition. If the workflow transition has a screen it will also see the values set in the form and comment added to the transition.
Context objects
- ${issue} - [com.atlassian.jira.issue.IssueImpl] Issue object
- ${description} - [String] Formatted issue description - wiki format already rendered to HTML
- ${proj} - [com.atlassian.jira.project.ProjectImpl] Project object
- ${project} - [org.ofbiz.core.entity.GenericValue] Project entity
- ${pkey} - [String] Project Key
- ${baseurl} - [String] Base URL of the application (ex. http://localhost:2990/jira)
- ${userKey} - [String] Current user (user who triggered the transition)
- ${comment} - [String] Comment submitted in the view
- ${commentLevel} - [String] Comment submitted in the view
- ${roleLevel} - [String] Comment submitted in the view
- ${actionId} - [Integer] The transition ID number
- ${cfUtils} - [lv.itidea.jira.plugins.workflow.pf.email.CustomFieldHelper] Plugin's utility class to help fetching the issue's customfield values
- ${i18n} - [com.atlassian.jira.web.bean.I18nBean] Bean for accessing the message translations
- ${currentMillis} - [java.lang.Long] current time in milliseconds
- ${stringUtils} - [org.apache.commons.lang.StringUtils] Apache Commons utility class
- ${dateTimes} - [com.atlassian.jira.datetime.DateTimeVelocityUtils] Provides methods for parsing Date
- ${dates} - [com.atlassian.jira.datetime.DateVelocityUtils] Provides methods for parsing Date
- ${dateFormatter} - [com.atlassian.jira.datetime.DateTimeFormatter] JIRA date time formatter class
- ${dateTimeStyle} - [com.atlassian.jira.datetime.DateTimeStyle] JIRA Date Time Style enum
- ${jirautils} - [com.atlassian.jira.util.JiraUtils] JIRA utility class
- ${jirakeyutils} - [com.atlassian.jira.util.JiraKeyUtils] JIRA utility class
- ${userutils} - [com.atlassian.jira.user.UserUtils] Bean for retrieving users
- ${jiraUserUtils} - [com.atlassian.jira.user.util.UserUtil] Bean for retrieving users and groups
- ${avatarService} - [com.atlassian.jira.avatar.AvatarService] JIRA Avatar service
- ${externalLinkUtil} - [com.atlassian.jira.web.util.ExternalLinkUtil] JIRA external link utility class
- ${cfValueEncoder} - [com.atlassian.jira.render.SwitchingEncoder] JIRA customfield value HTML encoder class
- ${projectManager} - [com.atlassian.jira.project.ProjectManager] JIRA project manager
- ${customFieldManager} - [com.atlassian.jira.issue.CustomFieldManager] JIRA custom field manager
- ${constantsManager} - [com.atlassian.jira.config.ConstantsManager] JIRA constants manager
- ${issueConstantWebComponent} - [com.atlassian.jira.web.component.IssueConstantWebComponent] JIRA constants image rendering class
- ${velocityhelper} - [com.atlassian.jira.util.JiraVelocityHelper] JIRA Velocity helper class
- ${urlcodec} - [com.atlassian.jira.util.JiraUrlCodec] JIRA URL query params encoding helper class
- ${urlModeAbsolute} - [com.atlassian.plugin.webresource.UrlMode] Instance of UrlMode.ABSOLUTE enum
- ${webResourceUrlProvider} - [com.atlassian.plugin.webresource.WebResourceUrlProvider] JIRA utility for formatting URLs
- ${build} - [com.atlassian.jira.util.BuildUtilsInfo] JIRA build information class
- ${textutils} - [com.opensymphony.util.TextUtils] Text utility class
- ${xmlutils} - [com.atlassian.core.util.XMLUtils] XML utility class
Use of Context Objects
Listed above objects can be referenced in the template using Velocity expressions.
Accessing issue fields
- ${issue.summary}
- ${description} - Rendered version of ${issue.description} field
- ${issue.description}
- ${issue.assigneeId}
- ${issue.assignee.displayName}
- ${issue.reporterId}
- ${issue.reporter.emailAddress}
- ${issue.priority}
- ${issue.priorityObject}
- ${issue.created}
- ${issue.updated}
- ${issue.dueDate}
- ${issue.resolutionDate}
- ${issue.status}
- ${issue.statusObject}
- ...
Accessing issue customfields
- $!{cfUtils.getValue($issue, "customfield_10000")} - Retrieving string representation of customfield value or null
- $!{cfUtils.getRenderedValue($issue, "customfield_10000")} - Retrieving rendered value of customfield or null
- $!{cfUtils.getVal($issue, "customfield_10000")} - Retrieving actual value object of customfield value or null
Accessing Checkbox and Multiselect list values (value of type java.util.ArrayList)
- $!{cfUtils.getVal($issue, "customfield_10000").get(0)} - Retrieving first selected option of checkbox or multiselectlist customfield (might be null!)
Accessing Radiobutton and Select list values (value of type com.atlassian.jira.issue.customfields.option.Option)
- $!{cfUtils.getVal($issue, "customfield_10000").getValue()} - Retrieving selected option name of radiobutton or (single) select list customfield (might be null!)
Accessing Cascading select list values (value of type java.util.HashMap)
- $!{cfUtils.getVal($issue, "customfield_10000").get(null)} - Retrieving selected 1st level option of cascading select list customfield (might be null!)
- $!{cfUtils.getVal($issue, "customfield_10000").get("1")} - Retrieving selected 2nd level option of cascading select list customfield (might be null!)
Accessing current user username
- ${userKey}
Accessing comment provided with transition
- ${comment}
Example
Here is an example of simple email template containing fields from issue.
#!html <p>This is ticket <b>${issue.key}</b> from <b>${issue.project.name}.</b></p> <p>And you have to do: $!{issue.summary} </p> <p>How to do it: #if (${issue.description}) ${issue.description} #else is not defined. #end </p> <p><b>Problem:</b> $!{cfUtils.getValue($issue, "customfield_10000")}</p> <p><b>Steps to reproduce:</b> $!{cfUtils.getRenderedValue($issue, "customfield_10001")}</p> <p><b>Remote user:</b> $!{cfUtils.getValue($issue, "customfield_10003")}</p> <p><b>Tags:</b> $!{cfUtils.getValue($issue, "customfield_10004")}</p> #if ($comment) <p> <b>${userKey}</b> commented: $comment </p> #end <p>Have a nice day!</br> ${issue.reporter.displayName} </p>
Updated