Assets support in Outbound notifications
Summary
Here we provide additional information and examples about how asset field data can be accessed within Outbound notifications template using Velocity. (Learn more about Assets)
Access to asset field data
In outbound notification template you can use the asset field data, getting it from the $context.issue.fields object.
Here is an example of asset field possible format in the $context
Velocity script example to use asset field data with ID customfield_10543:
#macro ( customIncludeAssetFieldText $fieldId)
#set ($fields = $context.issue.fields)
#set( $field = $fields.path($fieldId) )
#if($jemhUtils.isNotNull($field))
$jemhUtils.setFieldRendered()
"#getFieldName($fieldId)[$fieldId]":
#foreach($asset in $field.elements())
Item: $foreach.count
#foreach($attribute in $asset.path("attributes").elements())
"$attribute.findValue("name").asText()": $attribute.findValue("value").asText()
#end
#end
#end
#end
##_______ Test macro - include Asset field _______
#customIncludeAssetFieldText('customfield_10543')Setup to reveal asset filed attributes
In order to make asset field attributes visible in the $context, some Jira field configuration is required.
Go to your Jira site administration settings > Work items > Fields > [YOUR ASSET FIELD] > Actions > > Contexts and default values > Edit Assets object/s field configuration
On page Assets objects field configuration pick specific attribute in the field User interaction > Display these attributes in the issue view
and save the changes.
Once the new attribute is added, in subsequent webhook events $context will start to include it in the attributes property of the specific asset field.