Forums

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

get mentioned Username

Thomas Smith June 16, 2019

Hey guys, 


Is there a way to get the username of an application User that was mentioned on a ticket. 

def HowCanI = com.atlassian.jira.event.listeners.mention.MentionEventListener.getUsername()

Or this there a way to search via full name to get a user 
userManager.getUserByName("Thomas Smith") -> The username is tsmith


2 answers

2 accepted

1 vote
Answer accepted
brbojorque
Community Champion
June 16, 2019

Hi Thomas, if you have access to the comment data. Usually, the username is already there and it is currently formatted as [~username]

All you need to do is parse that to whatever you like.

Thomas Smith June 17, 2019

Hey Bryan, 

this is what I ended up doing, just filtered out the [~] and I had the username 

Like brbojorque likes this
1 vote
Answer accepted
Ilya Turov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 16, 2019

you are mistaking listener with the event. MentionIssueCommentEvent has getToUsers() method which will return you set of ApplicationUsers:

https://docs.atlassian.com/software/jira/docs/api/7.6.4/com/atlassian/jira/event/issue/MentionIssueCommentEvent.html

as for your second question, there's 

UserSearchService.findUsersByFullName(String fullName)

https://docs.atlassian.com/software/jira/docs/api/7.6.4/com/atlassian/jira/bc/user/search/UserSearchService.html

Thomas Smith June 17, 2019

Hey thanks for that, was super helpful! 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events