Set up email notifications containing Bundled Fields data
The dedicated custom field for Bundled Fields can be included in email notifications that Jira sends to you after creating or modifying an issue that contains that custom field. However, Bundled Fields configuration slightly differs from the one provided by Jira. To avoid problems with displaying Bundled Fields incorrectly, follow the instructions below.
In order to get a formatted custom field value in an email notification sent upon issue creation, mark the Bundled Fields custom field as renderable (for example, extend the RenderableTextCFType class).
This will enable choosing a renderer for the custom field in Jira fields’ configuration.
By default, the custom field’s contents are displayed in a .json format – which might be hard to read, especially when a lot of data is involved.
Here is how to increase the readability of that information:
Bundled Fields Renderer will only change the format of data being displayed in email notifications and in other forms of data exports. It won’t affect the way Bundled Fields are displayed in Jira, or the values associated with those fields. It works for standard Jira notifications.
Before you start, create a proper email template (HTML format) and a .vm file according to these instructions.
In a standard custom field’s configuration, you need to modify the issuecreated.vm
template with the following code that generates a formatted Bundled Fields value:
JIRA/atlassian-jira/WEB-INF/classes/templates/email/text/issuecreated.vm
...
#set ($bundledField = $customFieldManager.getCustomFieldObject("customfield_13700"))
#set ($bundledFieldType = $bundledField.getCustomFieldType())
#set ($bundledFieldValue = $issue.getCustomFieldValue($bundledField))
#set ($bundledFieldChangelogValue = $bundledFieldType.getChangelogString($bundledField, $bundledFieldValue))
#if ($bundledFieldValue)
$stringUtils.leftPad($bundledField.name, $padSize): $bundledFieldChangelogValue
#end
...
In order to generate HTML-formatted emails, add the formattedbundledfields.vm
template to issuecreated.vm
JIRA/WEB-INF/classes/templates/email/html/includes/fields/formattedbundledfields.vm
#disable_html_escaping()
#set ($customfield = $customFieldManager.getCustomFieldObject("customfield_13700"))
#set ($customfieldType = $customfield.getCustomFieldType())
#set ($customfieldValue = $issue.getCustomFieldValue($customfield))
#set ($changelogValue = $customfieldType.getChangelogString($customfield, $customfieldValue))
#set ($encodedChangelogValue = $textutils.htmlEncode($changelogValue, false))
#set ($changelogValueHtml = $encodedChangelogValue.replaceAll( "\n","<br/>"))
#if($customfieldValue)
<tr>
<th>#text($customfield.name):</th>
<td class="has-icon">
$changelogValueHtml
</td>
</tr>
#end
JIRA/WEB-INF/classes/templates/email/html/issuecreated.vm
...
<table class="keyvalue-table">
...
#parse("templates/email/html/includes/fields/formattedbundledfields.vm")
...
</table>
...
Make sure to use the proper ID of your target Bundled Field to getCustomFieldObject parameter (presented Bundled Field’s ID is only exemplary).
When the file configuration is ready, remember to restart your Jira.
If you can’t find the answer you need in our documentation, raise a support request. Include as much information as possible to help our support team resolve your issue faster.