/
Template Examples
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.
<!-- 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}} <!-- Using Variables to compare values with multiple functions. The following two examples can be compared: If Bug/Task it will print different outcomes--> <!-- Will be shown if the issue type is Bug --> {{#if (eq issue.issuetype “App install”)}} Hi guys, this is a Bug! {{/if}} <!-- A work item is a Task with the summary "Task for Cats and Dogs". The following will only print "Hi guys, work on this: Cats." --> {{/if}} {{setVariable “Task“ (eq issue.issuetype “Task”)}} {{#if Task}} {{setVariable “Remove” (remove issue.summary “Task for ”)}} Hi guys, work on this: {{{before (split Remove ' ') 1}}}
<!-- 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}}
<!-- 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}}
<!-- 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}}
<!-- Prints all people watching the issue --> {{#each issue.watchers}} {{this.displayName}} {{/each}} Pradeep Gupta Lee Gu
<!-- 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
<!-- 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}}
<!-- Prints the filename of the first attachment of an issue --> {{#withFirst issue.attachment}} {{this.filename}} {{/withFirst}} Thisisafilename.pdf
<!-- Prints the last comment of an issue --> {{#withLast issue.comment}} {{this.body}} {{/withLast}} This is the last comment
<!-- 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}}
<!-- 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
<!-- 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
<!-- Removes "Companyname" from every reporters name, to print only the Name --> {{remove issue.reporter “Companyname”}} Pradeep Gupta Companyname -> Pradeep Gupta
<!-- 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
<!-- 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