Displaying username from customfield

Tero
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 20, 2024

I'm using better pdf exporter (Apache velocity) for printing out PDF's with information from issue cards. The code below has been working as intended before but after upgrading to datacenter and updating all the apps it stopped working and is now only printing "$name2. $name1". I already tried replacing jiraUserUtils and seeing if Atlassian removed functions so it doesnt return anything anymore. It's supposed to print the full name from customfield_14216 in form of "J. Doe".

I noticed that by commenting out #set ($name = $DisplayName) and #else it works by retrieving assignee name, but I need the name to come from the custom field.

 

 

##Handler name
#set($approversField = $customFieldManager.getCustomFieldObject('customfield_14216'))
#set($approversValue = $issue.getCustomFieldValue($approversField))
#set($UserNameString = $approversValue.toString())
#set ($index3 = $UserNameString.indexOf('('))
#set ($UserNameBefore = $UserNameString.substring(0,$index3))
#set($AppliUser = $jiraUserUtils.getUserName($UserNameBefore) )
#set($DisplayName = $AppliUser.getDisplayName() )
#if ( $approversValue )
#set ($name = $DisplayName)
#else
#set ($name = ${issue.getAssignee().getDisplayName()})
#end
#set ($index = $name.indexOf(' '))
#set ($index2 = $index+2)
#set ($name1 = $name.substring(0,$index))
#set ($name2 = $name.substring($index,$index2))

 

Thank you in advance

1 answer

1 accepted

0 votes
Answer accepted
Tero
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 26, 2024

Resolved.

Replaced

#set($AppliUser = $jiraUserUtils.getUserName($UserNameBefore) )

with

#set($AppliUser = $userutils.getUserManager().getUserByName($UserNameBefore) )

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.12.4
TAGS
AUG Leaders

Atlassian Community Events