JMWE Cloud: @ Mentioning a User in a Jira Comment with JMWE and Nunjucks: A How-To Guide

JMWE Cloud: @ Mentioning a User in a Jira Comment with JMWE and Nunjucks: A How-To Guide

 

This KB article demonstrates how to “@” mention a user when creating a comment using the JMWE Comment issue(s) post function.

 Instructions

Consider the following script - it adds a mention for the user with the email address first.last@example.com :

{% set userAccountId = "first.last@example.com" | findUsers | first | userInfo("accountId") %} {{ "[~" + userAccountId + "]"}}

Line 1 sets the variable userAccountId by using the JMWE custom filter findUsers to retrieve that user’s accountId value. Line 2 inserts the “@” mention with the value retrieved in line 1.

The user who is currently logged in can be referenced like this:

{{ "[~" + currentUser.accountId + "]"}}

To reference the Reporter of an issue, use issue.fields.reporter.accountId:

This is a comment by: {{ "[~" + issue.fields.reporter.accountId + "]" }}

To find other work item fields that may contain Users, click on the Issue Fields tab in the Help toolbar in the Nunjucks tester.

See this documentation on the findUsers filter.

Custom filters | findUsers

See this documentation on the JMWE Comment Issues post function.

Comment issue(s)

See this Atlassian documentation on text formatting markup.

 Related articles