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

Branden Frederick July 26, 2013

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

2 votes
Answer accepted
RambanamP
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 26, 2013

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

Branden Frederick August 6, 2013
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