Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,295,767
Community Members
 
Community Events
165
Community Groups

JMWE Comment Issue Post Function

I want to notify the reporter of an issue that they forgot to complete or fill in a field, e.g. Build ID, Environment, etc.

I am open to other post functions, however, my question here is can I create a comment that sends an email to the reporter using the following format in the comment?

@username comment

how do I construct that "@username" in nunjucks?

I have tried using the Display message Post Function but that only works in View issue mode so the reporter won't always see it

I have tried Email User post function but that won't send to the user doing the transition

3 answers

2 accepted

1 vote
Answer accepted

Adding an @mention in the comment is actually possible using the following code:

[~accountid:{{issue.fields.reporter._accountId}}]

 which is the "wiki markup" syntax for @mentions.

However, note that mentions are currently broken on the "old" issue view - they won't display properly.

it doesn't seem to be generating the email that an @mention normally does or any notification

I'm sorry, I didn't think about that, but of course @mentions follow the same rule as any other Jira notification: Jira won't send notification emails to the author of the change, unless the recipient has opted to receive such "self-notifications" in their Preferences.

The workaround is to use the "run as" option of the post-function to create the comment as the "add-on user" (or another fixed user), so that it is never the same as the current user.

Like John M Funk likes this

And by the way, to answer the last line of your initial question, the same "trick" applies to the Email Issue post-function - if you use the "run as add-on user" option, the email will go out to the Reporter even when they're the current user.

Like # people like this

I have a similar requirement to mention user in comments from a single user picker custom field. I am using JMWE "Comment issue post-function". Should this work for custom field as well? We are on DC! 

However getting below error using the same code (for reporter) :

Message:
Compilation error(s):
script_ffca1a040c2bdd640f280424f6ac324b.groovy: 1: illegal colon after argument expression;
   solution: a complex label expression before a colon must be parenthesized @ line 1, column 12.
   [~accountid:{{issue.fields.reporter._accountId}}]

@subham patra can you share a screenshot of the post-function configuration?

HI @David Fischer _Appfire_  - PFB,

Case 1:

JMWE_Comment.JPG

Case 2: Here "Employee Name" is a user picker field. In the comment the username is printing as a plain text, hence jira notification is not being sent to the mentioned user. 

JMWE_Comment3.JPG

@subham patra that's because, i the first post function, you selected Groovy Expression as the comment type. Change it to Text or Groovy Template. 

I have tried that as well. Now it's printing as a text.

JMWE_Comment4.JPG

That's the Cloud syntax. The Server syntax is the one you used in the other post-function. For a user mention, it'll be:

   [~${issue.get("reporter").name}]

or 

 [~<%=issue.get("reporter").name%>]

which are synonymous.

Like subham patra likes this

Hi @David Fischer _Appfire_ - your suggested syntax applies to the "reporter"

[~accountid:{{issue.fields.reporter._accountId}}]

What's the syntax for @mentioning users not on the issue?

Hi @Ron Chan ,

what do you mean by "users not on the issue"? Explicit (fixed) users? In that case, you'd need to get their accountId (with JMWE, you can use the "Lookup user..." button on the Nunjucks editor toolbar) and insert it:

[~accountid:124342435:2342334234:23423423]
Like # people like this
0 votes
Answer accepted
John M Funk Community Leader Sep 02, 2020

@David Fischer _Appfire_  Can you post the expression for Cloud?

@David Reaves The whole post is about Cloud, what makes you think otherwise?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Jira Software

Upcoming changes to epic fields in company-managed projects

👋 Hi there Jira Community! A few months ago we shared with you plans around renaming epics in your company-managed projects. As part of these changes, we highlighted upcoming changes to epics on...

14,485 views 37 44
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you