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

This widget could not be displayed.

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

This widget could not be displayed.

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

This widget could not be displayed.

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?

This widget could not be displayed.

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

 

This widget could not be displayed.

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.

This widget could not be displayed.

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

This widget could not be displayed.

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

This widget could not be displayed.

com.atlassian.jira.user.util.UserManager#getUserByKey

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 Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

513 views 3 18
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