Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

AndreH
Contributor
May 9, 2013

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

0 votes
Answer accepted
AndreH
Contributor
May 13, 2013

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

works for the assigned group

0 votes
AndreH
Contributor
May 13, 2013

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>

0 votes
AndreH
Contributor
May 13, 2013

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

0 votes
AndreH
Contributor
May 13, 2013

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>

0 votes
Sameera Shaakunthala [inactive]
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.
May 9, 2013

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

AndreH
Contributor
May 13, 2013

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

Sameera Shaakunthala [inactive]
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.
May 13, 2013

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.
AndreH
Contributor
May 13, 2013

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)

0 votes
codelab expert
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.
May 9, 2013
Please try it with $ issue.getCustomFieldValue ("abc").getValue ();
AndreH
Contributor
May 13, 2013

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.

0 votes
AndreH
Contributor
May 9, 2013

And here is the issueassigned.vm -

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

0 votes
AndreH
Contributor
May 9, 2013

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>

Suggest an answer

Log in or Sign up to answer