In the JIRA Velocity email templates, how can I show the Display Names for userid's stored in custom fields?

Hello

I have in several places custom fields which are user pickers or multi user pickers. When I use the basic

$issue.getCustomFieldValue("customfield_10122")

line, the string that results is

userid(userid)

If the custom field is a multi-user-picker, then the resulting line is

[userid(userid1), userid2(userid2)]

Is there a way to instead display the Display Name of those users instead of their userid's?

Thank you

1 answer

1 accepted

some utility code for diffrent fields, check this

#set( $issueCustomField = $issue.getCustomField( $customFieldKey ) )
#if ($issueCustomField)
#set( $issueFieldValue = $issue.getCustomFieldValue( $issueCustomField ) )
#if ($issueFieldValue)
$stringUtils.leftPad($issueCustomField.name, $padSize): #if ($customFieldType == "select")
$issueFieldValue.value
#elseif ($customFieldType == "multiselect")
#foreach ($entry in $issueFieldValue)$entry.value#if ($velocityCount != $issueFieldValue.size()), #end#end

#elseif ($customFieldType == "version")
#foreach ($entry in $issueFieldValue)
$entry.getString("name")#if ($velocityCount != $issueFieldValue.size()), #end
#end

#elseif ($customFieldType == "user")
$issueFieldValue.displayName
#elseif ($customFieldType == "multiuser")
#foreach ($entry in $issueFieldValue)$entry.displayName#if ($velocityCount != $issueFieldValue.size()), #end#end

#elseif ($customFieldType == "datetime")
$dateformatter.formatDMYHMS($issueFieldValue)
#elseif ($customFieldType == "date")
$dateformatter.formatDMY($issueFieldValue)
#else
$issueFieldValue
#end
#end
#end

Awesome, thank you. The multiuser code works! And I've saved the rest for later, for future use. Very much appreciated!

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

Meet the AUG leaders of Northern Virginia

@Rachel Wright (Jira Genie), @Billy Poggi (AUG NOVA, DC), and @Dana Jansen (Confluence Queen) are just some of the folks that lead one of the world's most active Atlassian User Group (AUG)....

118 views 4 9
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