This template displays the number of users who authored a comment in the current work item. Each user is only counted once.
Configuration
To use the Count comment authors template, simply select it from the template grid. Filter by Comments to find it faster.
Parameters
This template does not require any additional parameter configuration.
Expert mode
If you switch to Expert mode you can see the formula field in the Expression Parser. You can now tweak the expression to create a custom formula field based on this template.
Expression
Jira expression:
issue.comments.map(comment => comment.author.displayName).reduce((a, b) => a.includes(b) ? a : a.concat(b), []).length
Display as
Number
Formatting style
Default (unformatted)
Details
1. What does the expression do?
This expression calculates the number of unique users who have written at least one comment on a work item. Each user is only counted once, no matter how many comments they made.
2. Step-by-step breakdown
Let’s break it down:
-
issue.comments: Refers to all comments on the current work item. -
.map(comment => comment.author.displayName): For each comment, this extracts the display name of the author (the person who wrote the comment). The result is a list of all comment authors’ names, including duplicates if someone commented more than once. -
.reduce((a, b) => a.includes(b) ? a : a.concat(b), []): This part goes through the list of names and builds a new list that only includes each name once (removing duplicates). It checks if the name (b) is already in the list (a). If it is, it skips it; if not, it adds it. -
.length: Counts how many unique names are in the final list.
3. Examples
Suppose a work item has these comments:
-
Alice comments
-
Bob comments
-
Alice comments again
The steps would be:
-
Extract authors: ["Alice", "Bob", "Alice"]
-
Remove duplicates: ["Alice", "Bob"]
-
Count unique authors: 2
4. Real-life use cases
-
Team activity tracking: See how many different team members have participated in a discussion on a work item.
-
Engagement measurement: Quickly measure how many unique contributors are involved in a ticket or task.
-
Quality assurance: Ensure that multiple people have reviewed or commented on a work item before it moves forward.