Apps documentation
Extension for Jira Service Management
Cloud Server/Data Center
Extension for Jira Service Management

Cloud

Server/Data Center

Documentation
FAQ
Release notes
Articles & Videos
Last updated Feb 1, 2021

Email notifications

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.

Batching email notifications (default in Jira 8.x)

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.

Changing the renderer

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:

Steps

  1. Go to Jira Administration > Issues.
  2. Open Field configuration.
  3. Select the Field Configuration that contains your custom field.
  4. Click Configure.
  5. Navigate to the chosen Bundled Fields’ custom field and click Renderers.
  6. Select [Extension] Bundled Fields Renderer.
  7. Click Update to save the change.
Bundled Fields Email Notifications - Change the Renderer
Bundled Fields Email Notifications - Change the Renderer
Info

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.

Standard notifications (Jira 7.x and older)

Note

Before you start, create a proper email template (HTML format) and a .vm file according to these instructions.

Emails in text format

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
...

Emails in HTML format

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>
...
Note

Make sure to use the proper ID of your target Bundled Field to getCustomFieldObject parameter (presented Bundled Field’s ID is only exemplary).

Tip

When the file configuration is ready, remember to restart your Jira.

Need help?

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.