Accessing multi-value fields

Some fields in Jira issues can contain collections of values (e.g. Versions, Labels, Multi-selects...). With smart values these types of fields can also be accessed, but depending on your need may need special syntax.

Examples

Let's assume the following fields and values are present on an issue:

Field type Name Selected values
Checkbox Equipment Computer, Monitor, Mouse
Multi-user picker QA Tester Barney Rubble, Fred Flintstone
Labels Labels label1, label2, label3

Simply specifying {{issue.Equipment}} does not work since the field contains a list of values. You can quickly create a list of values using the syntax: {{issue.Equipment.value}} but for other requirements you may need the full iterator syntax below.

To show these values in an automation rule, for example to include them in the body of an e-mail being sent with the 'Send e-mail' action we'd have to use the following smart-values:

Field type
Smart field syntax

What it prints
Checkbox, Multi-select
{{issue.Equipment.value}}

Computer, Monitor, Mouse
Checkbox, Multi-select
{{#issue.Equipment}} {{value}}{{^last}},{{/}}{{/}}

Computer, Monitor, Mouse
Checkbox, Multi-select
{{#issue.Equipment}} {{value}}{{/}}

Computer Monitor Mouse
Checkbox, Multi-select
{{issue.Equipment.value.join(" ")}}

Computer Monitor Mouse
Checkbox, Multi-select
{{issue.Equipment.value.join(" - ")}}

Computer - Monitor - Mouse
Multi-user picker
{{issue.QA Tester.displayName}}

Barney Rubble, Fred Flintstone
Multi-user picker
{{#issue.QA Tester}}{{displayName}}{{(name)}} {{/}}

Barney Rubble(barney) Fred Flintstone(fred)
Labels
{{issue.labels}}

label1, label2, label3

Reference

{{list}}

Iterates over a list and prints it. You can also reference further methods and properties.

{{issue.fixVersions.name}}

{{list.join(separator)}}

Iterates over a list and prints out items separated by given string.

{{issue.fixVersions.name.join(" - ")}}

{{#list}}{{.}}{{/}}

Iterates over a list and prints it. You can also reference multiple further methods and properties.

{{#issue.fixVersions}}{{name}} {{releaseDate}}, {{/}}

{{list.get(index)}}

The element at the specified index, where 0 denotes the first element in the array

{{issue.comments.get(1).body}}

{{list.getFromEnd(index)}}

The element at the specified index from the end, where 0 denotes the last element in the array

{{issue.comments.getFromEnd(1).body}}

{{list.first}}

The first element of a list

{{issue.comments.first.body}}

{{list.last}}

The last element of a list

{{issue.comments.last.author}}

{{list.size}}

The size of the list

{{issue.comments.size}}

{{#list}}{{#first}}..{{/}}{{/}}

Iterates over the list and only enters the "first" block on the first element. Can also use _first if the element has a method or property called first.

// Prints all comment bodies and places "First:" in front of the first comment)
{{#issue.comments}}{{#first}}First:{{author.key}}{{/}}{{body}}{{/}}

{{#list}}{{#last}}..{{/}}{{/}}

Iterates over the list and only enters the "last" block on the last element. Can also use _last if the element has a method or property called last.

// Prints all comment bodies and places "Last:" in front of the first comment
{{#issue.comments}}{{#last}}Last: {{/}}{{body}}{{/}}

{{#list}}{{^first}}..{{/}}{{/}}

Iterates over the list and enters the "first" block on every element except the first element. Can also use _first if the element has a method or property called first.

// Prints all comment bodies and places "Not First:" in
// front of all comments except the first
{{#issue.comments}}{{^first}}Not First:{{author.key}}{{/}}{{body}}{{/}}

{{#list}}{{^last}}..{{/}}{{/}}

Iterates over the list and enters the "last" block on every element except the last element. Can also use _last if the element has a method or property called last.

// Prints all comment bodies and places a comma after
// each except the last comment
{{#issue.comments}}{{body}}{{^last}},{{/}}{{/}}

{{#list}}{{index}}{{/}}

Prints the index of the current item. Can also use _index if the element has a method or property called index.

// The same as above but prints the index of the comment in front
{{#issue.comments}}{{index}}. {{body}}{{^last}},{{/}}{{/}}