Breadcrumbs

Count comments

📚

This template displays the number of comments in the current work item.

Configuration

To use the Count comments template, simply select it from the template grid. Filter by Comment 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?.length

Display as

Number

Formatting style

Default (unformatted)

Details

1. What does the expression do?

The expression counts the total number of comments on the current work item.


2. Step-by-step breakdown

  • issue: Refers to the current work item being viewed or processed.

  • ?.: This is called the "optional chaining operator." It safely checks if the property exists before trying to access it, preventing errors if something is missing.

  • comments: This is the list (or array) of all comments attached to the work item.

  • ?.: Again, safely checks if the comments property exists.

  • length: This returns the number of items in the comments list—in other words, the total number of comments.

So, the expression as a whole means: "If the current work item has a comments list, return how many comments there are. If not, return nothing."


3. Examples

  • If a work item has 5 comments, the expression returns 5.

  • If a work item has no comments, the expression returns 0.


4. Real-life use cases

  • Displaying the number of comments directly on a work item card or in a report.

  • Creating dashboards or filters to find work items with a high or low number of comments.

  • Highlighting work items that may need attention because they have many (or no) comments.