How Add Custom Field (Sprint) to Email Template

serwu July 5, 2021

I want to add a custom field value to an email template.
Did according to this instruction
https://developer.atlassian.com/server/jira/platform/adding-custom-fields-to-email/

I added to the file (WEB-INF\classes\templates\email\html\issueupdated.vm)
#parse("templates/email/html/includes/fields/customfield.vm")

Then I created a file "customfield.vm" (WEB-INF\classes\templates\email\html\includes\fields\customfield.vm)
Here is my code:

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

This code doesn't work. It doesn't display field values sprint ("customfield_10016")
Screenshot_1.png

1 answer

0 votes
serwu July 7, 2021

I solved my question.
In the file along the path (WEB-INF\classes\templates\email\html\issueupdated.vm)
Instead of the previous line, I inserted


#rowWrapperNormal("#parse('templates/email/html/includes/fields/customfield.vm')" '' 'wrapper-special-margin')

Then in the file "customfield.vm" along the path (WEB-INF\classes\templates\email\html\includes\fields\customfield.vm)
I pasted the code

#disable_html_escaping()
#set($customfield=$customFieldManager.getCustomFieldObject("customfield_10016"))
#set($customfieldvalue=$customfield.getValue($issue))
#set($sub=$customfieldvalue.toString().substring($customfieldvalue.toString().indexOf('name=')))
#set($substr=$sub.substring(5, $sub.indexOf(',')))
<table class="keyvalue-table">
#if($customfieldvalue)
                <tr>
                               <th>#text($customfield.name):</th>
                               <td>$substr</td>
                </tr>
                #end
</table>

Screenshot_1.png

Suggest an answer

Log in or Sign up to answer