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

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

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


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


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
Community showcase
Published Wednesday in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


189 views 0 4
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