...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
Excerpt |
---|
A variable looks up a value from the template context. This documents details on the variables available in JMWE and how to create custom variables. |
If you want to insert the value of a variable in your template, you can use the following syntax: {{ myVar }}
. This looks up for the myVar
variable from the context and displays it. Variable names can have dots in them which look up properties, just like in javascript.
Variables available in JMWE
On this page:
Table of Contents | ||||||||
---|---|---|---|---|---|---|---|---|
|
Variables available in JMWE
JMWE makes the issue, transition, linkedIssue, parentIssue,
...
now
and currentUser
variables available to templates. You can access their properties using "." or "[ ]". For example, you can access the current issue key using {{issue.key}}
.
...
width | 400px |
---|
...
...
On this page:
Table of Contents |
---|
issue variable
The issue
variable is used to insert data of the issue being transitioned.
...
For example:
{{issue.fields.labels}}
returns an array of label values, e.g. [ "1", "2" ]
{{issue.fields.reporter.name}}
returns the username of the reporter, e.g. carter
...
title | Click here to see some properties of the issue variable |
---|
...
Properties
...
Description
...
transition variable
The transition
variable is used to insert information of the transition being executed.
For example:
{{transition.transitionName}}
returns the name of the transition, e.g. Start Progress
{{transition.to_status}}
returns the status of the transition, e.g. In Progress
...
title | Click here to see the properties of the transition variable |
---|
...
linkedIssue variable
...
You can access the issue data by looking up at its properties.
For example:
{{issue.fields.labels}}
returns an array of label values, e.g. [ "1","2" ]
{{issue.fields.reporter.accountId}}
returns the accountId
of the reporter, e.g. carter
Expand | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
transition variable
The transition
variable is used to insert information of the transition being executed.
For example:
{{transition.transitionName}}
returns the name of the transition, e.g. Start Progress
{{transition.to_status}}
returns the status of the transition, e.g. In Progress
Expand | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||
|
context variable
The context
variable holds information passed around between post-functions in the same Shared, Scheduled, or Event-based Action, or in the same Sequence of post-functions. It can contain information provided by post-functions such as the Create Issue(s) post-function, as well as information added by Nunjucks templates using the {% setContextVar %}
Nunjucks tag. See passing variables within a sequence for more information.
The following properties are available by default, after a Create Issue(s) post-function runs in a sequence or Action:
context.newIssueKey
: stores the issue key of the last issue created by a Create Issue(s) post-function in the action.
context.newIssueKeys
: stores an array of the keys of all the issues created by any Create Issue(s) post-function in the action.
The following property is only available from post functions that belong to a shared action or Sequence of post-functions post function:
context.currentIssue
: if the post-function belongs to a Sequence of post-functions or a Shared Action, this variable contains the original issue being transitioned or modified.
The following property is available when the user modified at least one field on the transition screen (in a post-function), or the event-based action is triggered following a change to a field:
context.changelog
: returns a single changelog entry, in the format for a single entry in the values
property of the response documented here. For example:
Code Block |
---|
{
"id": "10001",
"author": {
"self": "https://your-domain.atlassian.net/rest/api/2/user?accountId=5b10a2844c20165700ede21g",
"accountId": "5b10a2844c20165700ede21g",
"emailAddress": "mia@example.com",
"avatarUrls": {
"48x48": "https://avatar-management--avatars.server-location.prod.public.atl-paas.net/initials/MK-5.png?size=48&s=48",
"24x24": "https://avatar-management--avatars.server-location.prod.public.atl-paas.net/initials/MK-5.png?size=24&s=24",
"16x16": "https://avatar-management--avatars.server-location.prod.public.atl-paas.net/initials/MK-5.png?size=16&s=16",
"32x32": "https://avatar-management--avatars.server-location.prod.public.atl-paas.net/initials/MK-5.png?size=32&s=32"
},
"displayName": "Mia Krystof",
"active": true,
"timeZone": "Australia/Sydney"
},
"created": "1970-01-18T06:27:50.429+0000",
"items": [
{
"field": "fields",
"fieldtype": "jira",
"fieldId": "fieldId",
"from": null,
"fromString": "",
"to": null,
"toString": "label-1"
}
]
} |
The following property is available when the user provided a comment on the transition screen (in a post-function), or the event-based action is triggered following the posting of a new comment:
context.comment
: the comment being added, in the format described in the response section here.
newIssueKey
The newIssueKey
variable holds the key of the newly created issue. This is applicable only in the Create/Clone issue post-function.
For example:
{{newIssueKey}}
returns the key of the newly created issue.
Issue {{newIssueKey}} has been created.
linkedIssue variable
The linkedIssue
variable, which is only available from post-functions that work on linked issues, is used to insert data of the linked issue being processed by the post-function.
For example:
{{linkedIssue.fields.description}}
returns the description of the linked issue being processed.
Expand | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
targetIssue variable
The targetIssue
variable, which is only available from post-functions that
...
allow specifying the issues to operate on, is used to insert data of
...
each target issue being processed by the post-function.
For example:
{{
...
targetIssue.fields.description}}
returns the description of the
...
target issue being processed.
Expand | ||
---|---|---|
| ||
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
parentIssue variable
The parentIssue
variable, which is only available from post-functions that work on the parent issue, is used to insert data of the parent issue being processed by the post-function.
For example:
{{parentIssue.fields.priority.name}}
returns the priority of the parent issue being processed.
Expand | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
currentUser variable
The currentUser
variable is used to insert information about the current user, i.e. the user triggering the transition. Only one property of the current user is available: accountId. To set a user-type field (such as Assignee, Reporter, or any custom User-picker field), use the accountId property.
For example:
{{currentUser.accountId}}
returns the accountId of the user triggering the transition, e.g. accountId:5ca5b1469a000c1180956957.
Use this to set a user-type field (such as Assignee, Reporter, or any custom User-picker field)
now variable
The now
variable is used to insert the current date and time. This is useful to save a transition's execution date/time in a custom field.
For example:
{{
...
now}}
returns the
...
{{currentUser.key}}
returns the key of the user triggering the transition, e.g. carter001
now variable
The now
variable is used to insert the current date and time. This is useful to save a transition's execution date/time in a custom field.
For example:
...
current date and time, e.g. 2016-09-30T13:57:23.608Z
nowObj
The nowObj variable represents Variables used in Nunjucks templates#now as a Moment.js object.
For example:
{{ nowObj }}
returns Variables used in Nunjucks templates#now as a Moment.js object.
{{ nowObj | date }}
returns current date as a date Object
{{ issue.fields.duedate | date('clone') <= nowObj }}
returns true
if the ticket is overdue.
User-defined variables
In addition to the above variables, you can also create your own variables within the template using the set Nunjucks tag.
For example:
{% set x = "High" %}
sets the value of the variable x to High. You can also set the variable to an object. For example: {% set assignee = issue.fields.assignee %}