You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
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.
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
you get an ApplicationUser object.
If you are working with them, then it's really easy to get a name from that
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()