Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Add Custom Field Value to Email Template

Christina Hiller
Contributor
July 22, 2019

I'm trying to add a custom field value to the create issue HTML email template, but stumbling.  The field is required, so there will always be a value present on issue creation.

Attempt 1:

I've followed the directions here: https://developer.atlassian.com/server/jira/platform/adding-custom-fields-to-email/?_ga=2.56485292.608403254.1563807890-1574526416.1556543036

When I add the customerfield.vm as indicated below

#disable_html_escaping()
#set ($customfield = $customFieldManager.getCustomFieldObject("customfield_15707"))
#if($issue.getCustomFieldValue($customfield))
<tr>
    <th>#text($customfield.name):</th>
    <td class="has-icon">      
        $textutils.htmlEncode($issue.getCustomFieldValue($customfield), false)
    </td>
</tr>
#end

 

Instead of the comma separated values of the field, I get this message: $textutils.htmlEncode($issue.getCustomFieldValue($customfield), false) attempt 1_JIRA instruction.png

Attempt 2:

I tried the suggestion in another article, but instead of the value, I get the label name a second time.

#disable_html_escaping()
#set ($customfield = $customFieldManager.getCustomFieldObject("customfield_15707"))
#set ($customfieldvalue = $customfield.getValue($issue))
#if($customfieldvalue)
<tr>
<th>#text($customfield.name):</th>
<th>$customfield</th>
</tr>
#end

and tried

#disable_html_escaping()
#set ($customfield = $customFieldManager.getCustomFieldObject("customfield_15707"))
#set ($customfieldvalue = $customfield.getValue($issue))
#if($customfieldvalue)
<tr>
<th>#text($customfield.name):</th>
<th>$customfieldvalue</th>
</tr>
#end

attempt 2_community suggestion.png

 

 

I can't tell if my issue is coming from the createissue.vm or customfield.vm or how to fix it.  any help/suggestions would be very much appreciated!

1 answer

1 accepted

0 votes
Answer accepted
Nic Brough -Adaptavist-
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 Champions.
January 11, 2017

Technically, no, JIRA hides tabs that contain only fields with no data when you're in the issue view.

The best cheat is to simply include a field you know will have data (you'll need a separate one for each tab).  If your field list for a tab does not include any mandatory fields, then you could reach for a scripted or message field (I've not tested this trick with the message fields from the JIRA Suite Utilities yet, but I think it still works - I used it to put text on tabs saying simply "the fields for this tab are all empty at present, please edit the issue and fill them in")

 

Andreas Schierz
Contributor
January 13, 2017

i used the Message Custom Field for View from JIRA Toolkit plugin,

How do i hide this field in case any field in a tab is not Empty?

Suggest an answer

Log in or Sign up to answer