display full user name with groovy

good day. 


on the transition I have a screen with a custom single user picker "approver". in post-functions I display this user's name in a comment with some text. when this comment is displayed, the user "approver' is written as userkey like jsmith (not the full name). 

how can Groovy be used for converting a userkey to a full user name? 

and can it be changed within this custom field, without using additional cf? 


8 answers

0 vote

can you explain how it's appearing in the comment? Is the object you have a String (the user key), or an ApplicationUser object?

Hi Jamie, 

I'm adding a comment with a standart post-function "Add a comment", not from a script. It is inserted as a string. As i understand there are no variants to format this value within this comment post-f, so I want to convert this name in a separate script or by more logical method, if it exists

0 vote

can you add a screenshot of the Add a Comment config? I'm not familiar with that... also not sure how you got the approver in there?

image2016-7-11 13:43:46.png

here it is a configuration, %{11021} is user picker cf, and it doesnt have a "cf Full name" property as the built-in user pickers have (reporter's full name, assignee's full name)

approver cf is on Screen, agent inserts value manually:

image2016-7-11 13:48:16.png


0 vote

You need to ask the authors of whatever plugin that comes from - not sure why you have used SR tags instead of theirs. Easy to do with SR though.

image2016-7-11 13:54:9.png

Sorry, but initially I just needed a script to convert a user key to full name to use it not only here but in other cases too

0 vote


how may it be used? 

The getUserByKey method will return an ApplicationUser object. You can use that object's getDisplayName() method (or the Groovified .displayName property) to get their name.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

357 views 0 6
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you