This page contains examples for use within Template configurations.
Examples cover different scenarios based on use cases and mainly show customer best practices or basic templating behavior.
You can copy and test all examples by removing unwanted comments in the snippets and insert the exmaples into any Template you are about to create.
If-else
HTML
<!-- Checks a custom gender field and generates the salutation accordingly -->
{{#if (exists issue.customfield_11111.raw)}}
{{#eq issue.customfield_11111.raw "m"}} <!-- check for the specific field value "m" -->
Dear Sir
{{/eq}}
{{#eq issue.customfield_11111.raw "f"}} <!-- check for the specific field value "m" -->
Dear Madam
{{/eq}}
{{else}} <!-- if the field is empty -->
Dear Sir or Madam
{{/if}}
Compare values via OR
HTML
<!-- this will print different outcomes depending on the priority -->
{{#or (eq issue.priority.name "High") (eq issue.priority.name "Highest")}}
We received your high priority Ticket!
{{else}}
Your Ticket has low priority!
{{/or}}
Check if a value is set and NOT a specific value
HTML
<!-- this will be executed if the issue summary is set but different then "Test"-->
{{#and (exists issue.summary) (compare issue.summary "==" "Test")}}
You created your work item with Test in the summary!
{{else}}
You created your work item without Test as part of the summary!
{{/and}}
Modify a datetime and compare it
HTML
<!-- Will print if a work item is older then 14 days ago or not -->
{{setVariable "14DaysAgo" (subtractDay now 14)}}
{{#if (isBeforeDay issue.created.raw 14DaysAgo)}}
Was created 14 days ago
{{else}}
Was not created 14 days ago
{{/if}}
Loop over an array
HTML
<!-- Prints all people watching the issue -->
{{#each issue.watchers}}
{{this.displayName}}
{{/each}}
Pradeep Gupta
Lee Gu
Map an array's property to a new array and loop over it
HTML
<!-- Prints all authors in the format "#. Name" -->
{{setVariable "commentAuthors" (pluck issue.comment "author.displayName")}}
{{#each (unique commentAuthors)}}
{{add @index 1}}. {{this}}
{{/each}}
1. Pradeep Gupta
2. Miriam Graham
Filter an array on a specific property
HTML
<!-- Prints all comments from the issue's creator -->
<!-- for Jira DC it would be issue.creator.key // author.key -->
{{#filter issue.comment issue.creator.accountId prop="author.accountId"}}
Created: {{format this.created.raw "dateMed"}}
{{this.body}}
{{else}}
{{/filter}}
Look for first/last entry of an array
HTML
<!-- Prints the filename of the first attachment of an issue -->
{{#withFirst issue.attachment}}
{{this.filename}}
{{/withFirst}}
Thisisafilename.pdf
HTML
<!-- Prints the last comment of an issue -->
{{#withLast issue.comment}}
{{this.body}}
{{/withLast}}
This is the last comment
Check on field values and print different outcomes
HTML
<!-- Returns depending on the value of a multiselectfield of an issue -->
{{#eq issue.customfield_11111 "Yes"}}
This is the Yes block
{{/eq}}
{{#eq issue.customfield_11111 "No"}}
This is the No block
{{/eq}}
Print only parts of an array
HTML
<!-- Prints only the first/last name of the assignee, instead of the whole name -->
{{{before (split issue.assignee ' ') 1}}}
John
{{{after (split issue.assignee ' ') 1}}}
Doe
Show me summaries of all linked issues / subtasks of an issue
HTML
<!-- Prints all issue summaries of linked issues -->
{{#each issue.issuelinks}}
{{this.inwardIssue.fields.summary}}
{{/each}}
This is a linked issue summary
This is a second linked issue sumary
<!-- Prints all subtasks of an issue -->
{{#each issue.subtasks}}
{{this.fields.summary}}
{{/each}}
Subtask summary 1
Subtask summary 2
Abbreviate/remove parts of a name
HTML
<!-- Removes "Companyname" from every reporters name, to print only the Name -->
{{remove issue.reporter “Companyname”}}
Pradeep Gupta Companyname -> Pradeep Gupta
Loop over an array and sort it
HTML
<!-- Print out all comments and sort them so the most recent will be toplevel -->
{{setVariable "YourVariableName" (sortBy issue.comment created)}}
{{#each YourVariableName}}
{{this.body}}
{{/each}}
Most recent comment
Second most recent comment
Getting information about Assets
HTML
<!-- Print out all asset names/labels -->
{{issue.customfield_xxxxx}}
Asset: Laptop, Asset: PC
<!-- Print out all asset names/labels but remove the word "Asset:" -->
{{remove issue.customfield_xxxxx “Asset:”}}
Laptop, PC
<!-- Iterate over every Asset picking a certain value like objectKeys -->
{{#each issue.customfield_xxxxx}}{{this.objectKey}}{{/each}}
PA-4 PA-5
<!-- Get information about the first value of a field within the array of the asset. In this case the attributes Name -->
{{issue.customfield_xxxxx.0.attributes.Email}}
PradeepG@yasoondemo.onmicrosoft.com