display full user name with groovy

SaidAslan July 10, 2016

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 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 11, 2016

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

SaidAslan July 11, 2016

how may it be used? 

Jonny Carter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 12, 2016

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.

Like # people like this
0 votes
SaidAslan July 11, 2016

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 votes
SaidAslan July 10, 2016

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

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2016

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.

0 votes
SaidAslan July 10, 2016

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 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2016

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?

0 votes
SaidAslan July 10, 2016

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 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2016

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events