Smart values allow you to access and manipulate pretty much any issue data from Jira. While they do take a little bit of learning, they add significant power and personality to your rules.
What are smart values?
Smart values are like placeholders that dynamically pull in data. For example:
- The smart value
{{now.plusDays(5)}}
references the current time and adds 5 days to it. - The smart value
{{issue.summary}}
will print off the summary of the issue.
Let’s look at a quick example. Say you wanted to add a comment to an issue on transition, and address the reporter and assignee of the issue that was transitioned by name. All you need to do is insert the right smart values in the appropriate places in your comment:
Example | Output |
---|---|
Hi We're now looking into your We'll get back to you soon with an update.
| Hi John Doe, We're now looking into your Update documentation on creating workflows. We'll get back to you soon with an update. John Smith |
Formatting smart values
Smart values use the Mustache library, preventing arbitrary code execution. To make a substitution, you need to wrap the value in double curly brackets, for example {{somevalue}}
.
Use a period to reference child elements, for example {{issue.key}}
.
Accessing issue fields
Use the field's name: {{issue.My custom field name}}
.
If the field is an object, reference the value within it. For example, if it is a user custom field, use:
{{issue.My user field.displayName}}
Field names are case insensitive and are translated using your rule actor's language setting. If you're trying to access custom fields with translated names in your smart values, then use the language set for your rule actor user.
If there are multiple custom fields with the same name, or have the same name as a system field, you can also use the custom field ID.
{{issue.customfield_10001}}
See Accessing issue fields for more detailed information.
Using #
for sections and lists
When you want to iterate over a number of items, use #
, and it does the same for everything captured by the smart value. When you use #
you must always end with {{/}}
to close it. In the example below, the action prints a list of comment authors.
{{#issue.comments}}Author: {{author.displayName}}{{/}}
To treat items as a number, when using math functions use {{#=}}
. For example, to perform a simple calculation to add 100 to an "Invoice Amount" custom field on your issue you can use:
{{#=}}{{issue.Invoice Amount}} + 100{{/}}
Default values
If a field or value doesn't exist, it typically just returns an empty value: {{invalid reference}}
.
If you must have a value, you can specify a default value. For example, when an "invalid reference" doesn't contain a value, you can print "Hello world" using {{invalid reference|Hello world}}
.
View available smart values and examples
Here you can find the list of all smart values and examples of how to use them: