Forums

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

Adding HTML content of Cutom fields in Email template

Syed Farath Sayeed April 10, 2018

Hi All,

I would like to add HTML content of my custom field into the email template.

By following these links:

https://confluence.atlassian.com/jira060/customising-email-content-370705824.html

https://developer.atlassian.com/server/jira/platform/adding-custom-fields-to-email/

I could successfully add the custom fields to the sent email, but it is in the plain text format. So now how do I configure it to as html content?

Any help is appreciated.

I am using JIRA 7.7.1.

Thanking you in advance,

SD

1 answer

1 accepted

0 votes
Answer accepted
Shaun S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 11, 2018

Hi Syed,


You can include your custom field in HTML emails by modifying a different set of templates.


1. Create a template for your custom field. This is where you can modify how it is rendered in the email. Save it in <jira_install>/atlassian-jira/WEB-INF/classes/templates/email/html/includes/fields

Below is an example:

mycustomfield.vm

#disable_html_escaping()
<tr>
<th>$stringUtils.leftPad($issue.getCustomField("customfield_10400").name, $padSize):</th>
<td>$issue.getCustomFieldValue("customfield_10400")</a></td>
</tr>


2. You'll want to modify the event notification templates that you want to include the custom field. For the sake of example, let's say we want the custom field included in the "Issue Created" event email.

Edit the template found at <jira_install>/atlassian-jira/WEB-INF/classes/templates/email/html/issuecreated.vm

Add the custom field template you just created to the key-value table:

<table class="keyvalue-table">
.....
#parse("templates/email/html/includes/fields/priority.vm")
#parse("templates/email/html/includes/fields/reporter.vm")
#parse("templates/email/html/includes/fields/securitylevel.vm")
#parse("templates/email/html/includes/fields/timetracking.vm")
#parse("templates/email/html/includes/fields/mycustomfield.vm")
</table>


3. If you don't have template caching disabled, you'll want to restart the Jira service to apply the changes.


Cheers!

Syed Farath Sayeed April 12, 2018

Thanks for your reply @Shaun S. I solved my problem later in the same way as you described but I used a slight different snippet for mycustomfield.vm, because with the snippet you defined will not include line breaks or any other or white spaces.

I used the following to solve my problem:

#if ($issue.getCustomFieldValue("customfield_10500"))
<div class="text">
<strong>Description:</strong>
<pre>
$issue.getCustomFieldValue("customfield_10500")
</pre>
</div>
#end

Thanks again.

Greg Raddemann September 24, 2018

Is it possible to add custom fields to the automated 'issue created' email in JIRA Cloud?

Thanks for your help!

Suggest an answer

Log in or Sign up to answer