Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Can I get a user's full name from their username or user key?

Edited

I am writing a Groovy script in Scriptrunner for Jira. I want to get a user's display name (full name). I have both the username and the jira user key (i.e. JIRAUSER00000). I'm finding a lot of articles for how to get the username from the full name, but I want to do the opposite because I want to display a user's name, and I think it looks nicer to display their full name rather than just their username. For some reason, I'm not finding a lot about that online. What's the easiest solution for this?

In case this information helps, I am getting the user from a multi-user picker custom field.

1 answer

1 accepted

2 votes
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jan 16, 2023

Depends on what type of user object you have got, but I tend to work with "applicationUser"s.

This is because when you do stuff like 

issue.getAssigneeUser()

you get an ApplicationUser object.

If you are working with them, then it's really easy to get a name from that

issue.getAssigneeUser().getDisplayName() 

will fetch what they currently have as their name.

However, ApplicationUser is not the same as the other (several) types of user you can get.  It's usually quite easy to work out an ApplicationUser from most of the other types though.  

Mainly through "userManager" - in your case, you should be able to throw the id into userManager.getUserByKey or .getUserByName or .getUserById.  So, something like

def usersDisplayName = userManager.getUserByKey(JIRAUSER00000).getDisplayName()

Thank you! Seems like, when using issue.getAssigneeUser() or issue.getReporterUser(), adding .getDisplayName() did what I needed.

Suggest an answer

Log in or Sign up to answer