First comment

📚

Displays the text of the first comment posted in the current work item.

If there is nothing to display, the result will be “None”.

Configuration

Select Custom text formula in the template gallery after clicking Create formula field.

Choose Jira expression in the parsing mode dropdown. Click here for additional information.

jira_expression_parsing_mode.jpg

Expression

Expression

Jira expression:

issue?.comments[0]?.body?.plainText == null ? '' : issue?.comments[0]?.body?.plainText

The text will be returned using wiki markup, e.g. bold text will be shown as *bold text*.

Details

1. What does the expression do?

The expression retrieves the text of the first comment posted on the current work item. If there are no comments, it returns an empty string.

2. Step-by-step breakdown

Let’s break it down:

  • issue?.comments[0]: This tries to access the first comment (index 0) of the current work item. The ? (optional chaining) means it won’t cause an error if there are no comments.

  • ?.body?.plainText: This continues to safely access the body of the comment and then its plain text content, again using optional chaining to avoid errors if any part is missing.

  • == null ? '' : ...: This checks if the plain text of the first comment is null (or doesn’t exist). If so, it returns an empty string (''). Otherwise, it returns the plain text of the first comment.

3. Examples

  • If the work item has at least one comment, and the first comment says “Looks good!”, the expression will return: Looks good!

  • If there are no comments, the expression will return an empty string (which the template displays as “None”).

4. Real-life use cases

  • Displaying the first feedback or question posted on a work item directly in a dashboard or report.

  • Quickly surfacing the initial comment for review or triage purposes.

  • Creating custom fields or views that highlight the first user interaction on a work item.