Showing Jira fields within a Scriptlet

Summary

Scriptlets are used to provide pre-defined sections of Html content for Ad-Hoc notifications and are able to retrieve values from all Jira Fields.

How Jira Fields values are retrieved

Most Jira Fields can be accessed by using $issue.getField(). However, Custom Fields require $issue.getCustomFieldValue("customfield_10116") to gather their values. As the Custom Field Id’s are used to find the Custom Field value, it means that they will need to be changed within the Scriptlet to work within your Jira instance.

Example Scriptlet

This Scriptlet example gathers all of the Jira Field values and displays them in a format that is similar to the Jira Issue Page. This Scriptlet has two features to restrict any unnecessary content from being shown within the Ad-Hoc notification:

  1. Check if Fields are empty. Fields will not be shown when they are empty.

  2. Check if comments are internal comments. If they are internal comment then they will not be shown. (This only applies to Jira Service Desk Projects).

Example Scriptlet File

 

Importing the example Scriptlet

To import the Scriptlet go to JEMH > Template Sets > Templates > Import Template Set and select the Downloaded Scriptlet file. This will then place the Scriptlet within the “Scriptlets for Ad hoc” section in Template Sets.

 

Inserting a Scriplet into a Ad-Hoc notification

To insert the Scriptlet into the Ad-Hoc notification press Insert > Add Template within the the text editor. This will then display the content into the Comment text editor.

 

Example Email that used this Scriptlet

Below is a demonstration of how the Scriptlet content is displayed within an email.