Custom email field not showing correct field value

In Jira 5.0 we have several custom fields. These customizations have always worked in the past in the html emails. Code below now is just showing garbarge like [com.atlassian.crowd.embedded.ofbiz.OfBizUser@b6b373d2] for the value rather than the jira user name that's stored in the field via the multi user picker. The other custom fields show the correct data in the html email. Any idea on what's going on?

#if ($issue.getCustomFieldValue("customfield_10131"))
<tr valign="top">
<td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:${textSubtleColour};">
$stringUtils.leftPad($issue.getCustomField("customfield_10131").name, $padSize):
</strong>
</td>
<td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 0 10px 0;width:100%;">
$issue.getCustomFieldValue("customfield_10131")
</td>
</tr>
#end

1 answer

This widget could not be displayed.

Which bit is not working? It should be:

$issue.getCustomField("customfield_10131").name

which will prevent an error if the field has no value set. And are you sure this is a multi not a single user picker? This code should not work for a multi user picker. You need to iterate over the users calling .name on each one. I don't see how this worked previously.


In our Jira 4.2 production instance, below is the code that's in the issuessummary.vm for html templates and the email is showing the two users that were added to the issue as UAT asignments. I thought the same thing as well that it should have to be iterated through with a foreach..end statement. So I was just carrying the same change forward to 5.0. I can replace the code with the foreach..end statement but I'm not fully aware of the syntax for custom fields.

Email shows this:
UAT Assignments: [ceswift,tlking]

#if ($issue.getCustomFieldValue("customfield_10131"))
>$stringUtils.leftPad($issue.getCustomField("customfield_10131").name, $padSize): $issue.getCustomFieldValue("customfield_10131")
>
#end

Terry, this is caused by a toString() overriden method. In Jira 5, this is missing and the default toString() method was called, producing the result you see.

So: either do what Jamie said, or "patch" jira class com.atlassian.crowd.embedded.ofbiz.OfBizUser with a nicer toString() method.

That's what I thought at first, but surely the value should be a collection of OfBizUsers, not one.

I used the following in the issuecreated.vm for the html emails and it worked. Thanks.

#if ($issue.getCustomFieldValue("customfield_10131"))
<tr valign="top">
<td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:${textSubtleColour};">
$stringUtils.leftPad($issue.getCustomField("customfield_10131").name, $padSize):
</strong>
</td>
<td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 0 10px 0;width:100%;">
#foreach ($CustomField in $issue.getCustomFieldValue("customfield_10131"))
$CustomField.name,
#end
</td>
</tr>
#end

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

44 views 4 5
Join discussion

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