Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to mention multiple users in comment by Post Function (Script Runner or JMWE)

Nagaraju November 19, 2022

It is possible to mention multiple users from the Multiple User Picker field in a comment for Jira Data Center.

2 answers

1 accepted

2 votes
Answer accepted
Alex Koxaras _Relational_
Community Champion
November 19, 2022

@Raju I would expect that to be easy to do with a for loop and after acquiring the users' id.

TN Raju November 20, 2022

@Alex Koxaras _Relational_  thanx for reply.

Iam getting users list by using loop, but we need to add '~' before every username.

Alex Koxaras _Relational_
Community Champion
November 20, 2022

@TN Raju with JMWE I've inserted during a transition the "Add Comment" post function and entered the following code:

def users = issue.get("customfield_17251")
def commentString=""
for (user in users){
commentString += "[~" + user.username.toString() + "] "
}
commentString + "this is a comment"

The customfield_17251 is my multiuser picker field. So replace this with your CF and adjust the final line to your liking:

comment.png

Let me know if that works our for you.

Nagaraju November 20, 2022

@Alex Koxaras _Relational_ Perfectly Worked.
Thank you so much.

Alex Koxaras _Relational_
Community Champion
November 20, 2022

Good to know that! 

Nagaraju November 20, 2022

0 votes
Aaron Marsh
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 6, 2024

This works for Cloud, not sure about DC

 

This would work using the JMWE Comment Issue Post Function, replace the X's with your custom field ID. This @ mentions each user in a multi user field on a separate line. 

{% for user in issue.fields.customfield_XXXXX %}

[~{{ user.accountId }}]

{% endfor %}

The following does the same but keeps all mentions on the same line

{% for user in issue.fields.customfield_XXXXX %}[~{{ user.accountId }}]{% endfor %}

 

Suggest an answer

Log in or Sign up to answer