robotsnoindex
robotsnoindex

Smart values allow you to access and manipulate issue data within Jira. They can add significant power and complexity to your rules. For example, the smart value {{now.plusDays(5)}} references the current time and adds 5 days to it. and {{issue.summary}} will print off the summary of the issue.


Example

You can use smart values to add a comment to an issue on transition, addressing the name of the reporter and assignee of the issue.

Hi {{reporter.displayName}}

We're now looking into your issue {{issue.summary}}.

We'll get back to you soon with an update.

{{assignee.displayName}}

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, e.g. {{value}}.

Use a period to reference child elements, e.g. {{issue.key}}.

Finding a smart value

For the majority of cases, you can choose a smart value from our reference documentation:

You can access the value in custom fields using the custom field's name, e.g. {{issue.Team Leader}}. Field names are case insensitive and are translated using your rule actor's language setting. Learn more about accessing issue fields.

If your instance is highly customized, you will need to investigate the REST API to find the right smart value. Learn more about finding the smart value for field.


Testing a smart value

To test what a smart value returns:

  1. Create a rule using the Manual trigger with Log action. 
  2. Navigate to an issue, and select Rule executions to manually trigger your rule.
  3. The result displays in the audit log, as shown below.


Chaining smart value functions

You can apply multiple transformations in one step by chaining your smart functions.

You can change an issue’s summary to lowercase, only use the first 10 characters, and add !! to the end using the following example.

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

Using smart values with sections and lists

When working with smart values that have multiple items, you can use # with the smart value to apply your rule to every item in the list. For example, the smart value {{issue.comments}} is used to access and return an issue's comment. However, if the issue has multiple comments, the smart value {{#issue.comments}} would make your rule iterate on each comment individually. When using #, you must close the expression with {{/}}.

For example, to print a list of comment authors:

{{#issue.comments}}Author: {{author.displayName}}{{/}}

To treat items as numbers, use {{#=}} when using a math function. For example, to add 100 to an Invoice amount custom field:

{{#=}}{{issue.Invoice Amount}} + 100{{/}}


Default values

If a field or value doesn't exist, it will return an empty value: {{invalid reference}}. You can specify a default value to prevent this.

For example, when invalid reference doesn't contain a value, you can print Hello world using {{invalid reference|"Hello world"}}.

Create your own smart values

You can define your own custom smart values using the Create variable action.

Learn more

Check out how we use smart values in our Jira automation template library.