Jira Automation smart value
distinct in Jira Automation: syntax and examples
distinct returns the items of a list once each, without duplicates. The Atlassian page uses it after a Lookup issues action to print each parent only once. It also works on any other list, such as the authors of comments.
Syntax
{{list.distinct}}
Works on
- Fields: any list, including lists of values taken from a property, such as issue.comments.author.
- Returns: a list without repeated items, which you can chain with size or join().
Examples
{{issue.summary.replace("Hello World!","a,b,a,c,b").split(",")}}Build a list with repeated values to see the starting point: five items, with a and b twice.
Result:
a, b, a, c, bRun on Jira Cloud on .
{{issue.summary.replace("Hello World!","a,b,a,c,b").split(",").distinct}}Remove the repeats from the same list.
Result:
a, b, cRun on Jira Cloud on .
{{issue.summary.replace("Hello World!","a,b,a,c,b").split(",").distinct.size}}Count how many different values the list holds.
Result:
3Run on Jira Cloud on .
{{issue.comments.author.size}}Count the comments by author, with repeats.
Result:
2Run on Jira Cloud on .
{{issue.comments.author.distinct.size}}Count how many different people commented. Two comments from the same user count once.
Result:
1Run on Jira Cloud on .
{{issue.summary.replace("Hello World!","b,a,b").split(",").distinct.join("+")}}Chain distinct with join() to print the unique values on one line.
Result:
b+aRun on Jira Cloud on .
Pitfalls
- distinct keeps the order of the first appearance. The values b, a, b become b and a, not a and b.
- The unique count is
distinct.size: distinct comes first, and the function that reads the list follows it. - On a work item without duplicates distinct changes nothing: the two labels checkout and demo print the same with and without it.