Custom fields in outgoing HTML issueassign.vm do not show proper data in Email

I have created several custom fields in Jira -

  • Assigned Group (Group Picker)
  • Customer (User Picker)
  • Planned Start (Date Picker)

I have added these fields to outgoing HTML emails (issueassigned.vm) and I have also created the corresponding fields (assignedgroup.vm, customer.vm and plannedstart.vm)

When the email is sent out, the data in the email does not match the true data values.
For Example -
Assigned Group: [com.atlassian.crowd.embedded.impl.ImmutableGroup@14cd6]
(This should be Uno for the Group Name)

Customer: aarockia:10001
(This should be Arockiasamy, Anthony)

Planned Start: 2013-05-11 00:00:00.0
(This Should be 05/11/13 12:00 AM)

8 answers

1 accepted

$issue.getCustomFieldValue("customfield_11000").get(0).name

works for the assigned group

Here is a sample of the assignedgroup.vm file -

#disable_html_escaping()

#if ($issue.getCustomFieldValue("customfield_11207"))

<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};">#text("Assigned Group"):</strong>

</td>

<td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 0 10px 0;width:100%;">

$issue.getCustomFieldValue("customfield_11207")

</td>

#end

</tr>

And here is the issueassigned.vm -

#parse("templates/email/html/includes/fields/assignedgroup.vm")

Please try it with $ issue.getCustomFieldValue ("abc").getValue ();

I tried this setup -

#disable_html_escaping()
#if ($issue.getCustomFieldValue("customfield_11207"))
<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};">#text("Assigned Group"):</strong>
</td>
<td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 0 10px 0;width:100%;">
$issue.getCustomFieldValue("customfield_11207").getValue();
</td>
#end
</tr>

And it does not work.

Try 'getDisplayName()'

Following worked for me, for multi-user custom fields. You can try the same for group picker too:

#if($issue.getCustomFieldValue("customfield_xxxxx"))#foreach($c_p in $issue.getCustomFieldValue("customfield_xxxxx"))$c_p.getDisplayName()#if($velocityCount != $issue.getCustomFieldValue("customfield_xxxxx").size()), #end#end#{else}Not Specified#end

(replace 'customfield_xxxxx' with the actual text ID of the required custom field in your instance)

For date picker you can use the dateformatter,

#if($issue.getCustomFieldValue("customfield_xxxxx"))$dateformatter.formatDateTimePicker($issue.getCustomFieldValue("customfield_xxxxx"))#{else}Not specified#end

Refer to Atlassian's developer documentation and javadocs for more information. (Google them)

Also, following question might be helpful:

https://answers.atlassian.com/questions/154833/velocity-how-to-get-user-ids-in-a-multi-user-custom-field-into-a-comma-separated-string

I tried this setup -

#disable_html_escaping()
#if($issue.getCustomFieldValue("customfield_10308"))$dateformatter.formatDateTimePicker($issue.getCustomFieldValue("customfield_10308"))#{else}Not specified#end

and it does not work

I hope you already know how to make VM teplate changes effective without restarting JIRA.

Then, do the following,

  1. Go to JIRA Administration --> Mail Queue
  2. Flush Mail Queue once to make sure there's no pending delivery
  3. Make changes and save the template file.
  4. Refresh Mail Queue. What do you see? Normally there should be one or several mail messages queued. Also, if each item begins with text 'ERROR:', then again there's a problem.
  5. Flush the Mail Queue. Wait a minute and two and check your inbox. If you have received an e-mail with a big stacktrace (error log kind of thing), paste it here so we can look at the problem.

All I am missing is the Group Picker.... Any idea how this is formated?

Using the following type of format I got the user picker and the date to work properly... now I'm just missing the Group Picker custom field

#authorlink($issue.getCustomFieldValue("customfield_10094").name)

I got the Custom user field to show properly in the email by using -

#disable_html_escaping()
#if ($issue.getCustomFieldValue("customfield_11400"))
<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};">#text("Customer"):</strong>
</td>
<td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 0 10px 0;width:100%;">
#authorlink($issue.getCustomFieldValue("customfield_11400").name)
</td>
#end
</tr>

All I am missing is the Group Picker.... Any idea how this is formated?

I got the date to work as well with the following -

#disable_html_escaping()
#if ($issue.getCustomFieldValue("customfield_10308"))
<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};">#text("Planned Start"):</strong>
</td>
<td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 0 10px 0;width:100%;">
$dateformatter.formatDMYHMS($issue.getCustomFieldValue("customfield_10308"))
</td>
#end
</tr>

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