Smart value basics

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

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?

For example the smart value {{now.plusDays(5)}} references the current time and adds 5 days to it. {{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:

Why the curly brackets?

We use the Mustache library to do our smart substitutions. We used this for security reasons as it won't allow for arbitrary code execution. The downside is that the syntax can sometimes be a little awkward. To make a substitution you need to wrap the value in "double curly braces", for example {{somevalue}}.

To reference child elements you simply use a dot, for example {{issue.key}}

How do I know what smart value to use?

90% of the time, you can simply choose the smart value from the available values in our reference guide.

We also recommend reading the following more detailed sections on specific uses of smart values:

If you need to apply multiple transformations in one step, you can chain functions. For example, to change an issue's summary to lowercase, and to only use the first 10 characters, and also to add "!!" to the end you could chain these together as:

{{issue.summary.toLowerCase().substring(0, 10).concat("!!")}}

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 do: 

{{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 "invalid reference" doesn't contain a value, you can print "Hello world" using {{invalid reference|Hello world}}.

Last modified on Apr 21, 2021

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.