Customise the Content / Comment Header

Summary

The Comment Header allows you to prefix specific content onto comments when they are processed by JEMHC.

Creating a Content Header template

Comment header content is create and modified through the use of a template. Templates are found within Notification > Template Sets.

When you press create it will show a Form where you specify the Template Name, Theme, Template Set Type and the Template to copy content from.

Once the template has been created, you are able to customise the content that is shown within the comment header. Below is the content that would be shown if the content was copied from the “Comment Header Jira” template.

Information about the data available to you for use within a Template’s content can be found here.

Changing the Template that is used by the Profile

Once the template has been created you will then have to select the template within the Profile so that it will then be applied within the comment. To change the template you go to Profile > Project mapping > Templates and press Edit.

You will now be able to select the Comment Header Template that was just created.

Choose the sender categories this should apply to

Within the Profile you are also able to set when the Content Header should be applied and for the scope (email users and or Jira users). See Profile > Project Mapping > Issue > Comment > Content Headers

Available options are:

  • Inherited

  • Don’t add header

  • Add header for email users

  • Add header for email users and Jira watchers

Headers are not added for Jira users/reporters as the ‘user’ object that creates the issue and/or comment clearly identifies who is making the comment.

 

Example Content Header

Once you have the comment header configured you will then see that new comments will have the new comment header applied.

Data available for use within a Template’s content (with usage examples)

The data available to you for use within your template can be found by expanding the Preview Context and Velocity Context sections.

In the following examples illustrated, you can at any point click on the Preview button at the bottom of the template content box.

This will allow you to see how your template will render when in use, given the example Preview Context shown on this section.

Preview Context data

Preview Context data is specific to the context in which your template is used and is available at render time. From the example above we can see that the context for an incoming email shows the address from which the email was sent, and the intended recipients.

To output the sender’s email address in your comment header, create the following template.

$context.from.textValue()

The email body will automatically be output after the contents of a template. The above template therefore results in the value of the sender’s email address being added to the top of all issue comments and newly created issue descriptions. This would then render as shown below, given the data shown in the example Preview Context.

You can of course do more complicated things such as create links, or provide information about the incoming data.

From: (mailto:$context.from.textValue()) with the subject $context.subject. The email was sent to $context.recipients.size() recipients, one of whom has the email address $context.recipients[0].textValue().

This would then render as shown below, given the data shown in the example Preview Context.

An important point to note here is that to access any of the data held within the preview context, you must prefix the named fields with $context, e.g. $context.from.textValue().

In the above example the recipients field has multiple entries surrounded by square braces. These data structures are called “arrays” and we can access each element by its positional index within the list as shown above with $context.recipients[0]. The positional indices for arrays start at zero, therefore the first element is found at $context.recipients[0] the second at $context.recipients[1], and so on.

Velocity Context data

Velocity Context data is also available to your template at render time but provides more general utilities for your use.

An example template using the jemhDateUtils context is shown below. Note again that to access any features of a context, you must prefix all features with the name of the context, here, $jemhDateUtils.

$jemhDateUtils.nowDate()

This would then render as shown below given the data shown in the example Preview Context, and would show the date the comment was created.

The general utilities provided are hyperlinked to the related online documentation where possible to enable you to understand what methods may be available.