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
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!
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is it possible to add custom fields to the automated 'issue created' email in JIRA Cloud?
Thanks for your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.