- Get started
- About
- Glossary
- First steps
- Migration to Cloud
- Integrations points
- Create issue from template
- Recreate issue
- Apply template
- Apply template post function
- Legacy automation action
- Template custom field on issue create screen
- Apply template via issue property
- Configuration
- Repository
- Template's configuration
- Using templates
- Copy Epic
- Copy links and linked issues
- Copy Subtasks
- Copy Initiatives
- Default templates
- Using Variables
- Static variables
- Dynamic variables
- Smart defaults
- Basics
- Smart issues
- Smart users
- Smart dates
- Smart project
- How to use smart defaults
- Security
- Security statement
- App permissions
Automation
This chapter provides information on how to use the power of Automation and Issue Templates together.
At first, when we think about Jira Automation and ITC cooperation, we may try to find a custom action, which will apply template to an issue according to our rule. That would be the easiest scenario to apply a template to an issue. Unfortunately, due to Jira limitations, it’s not possible to add a new action to Automation.
However, we can get around these restrictions, by using Automation’s Create Issue action with help of the special issue.templates.automation property. What we need you to do is to delegate the job of creating the issue to the Automation and instruct the ITC app to apply the template right after the issue has been created. If you are new to Automation’s Create issue action learn more in official Atlassian documentation.
Configure the action to create a “dummy“ issue with all the required fields for the particular issue type you want to use. Then, expand the More options setting and replace the content with following:
{
"properties": [{
"key": "issue.templates.automation",
"value": {
"applyTemplate": "TEMPLATE-1"
}
}]
}
Above will instruct the ITC app to “applyTemplate“ with issue key equal to TEMPLATE-1.
There are numerous triggers that you can use with Create issue action and apply the template property. We found some of them very interesting and created short videos showing all the configuration steps, which you will find in following sections.
How to schedule creation of issues from templates using Jira Automation?
One of available options to create an issue from template is to use Automation’s Scheduled trigger with Create issue action. Applying template to newly created issue is possible only if you change Create issue action’s properties, as in example below:
{
"properties": [{
"key": "issue.templates.automation",
"value": {
"applyTemplate": "TEMPLATE-1"
}
}]
}
where TEMPLATE-1 is a template key.
How to trigger creating issues from template from external tool?
Following example presents steps you need to take in Jira Automation and external tool (here: Postman) to create issues from template.
Jira Automation steps
- Create a template in Templates Repository. Use the {{ }} mark to set the variable.
NoteBy default, variables use [ ] mark. Read more about variables configuration here.
- Navigate to Project settings > Automation.
- Click Create rule.
WarningRemember to change the Actor of the rule to a real user with all required permissions to view templates and create issues in the target project. If you leave the Default Actor - Automation for Jira won’t work.
- In New trigger, select Incoming webhook.
- In Execute this automation rule with select No issue from the webhook.
- Click Save.
- In Add component, click New action > Create issue.
- Select:
- Project
- Issue type
- Choose fields to set (for example: Epic Name).
- Type the Summary and complete fields selected in Choose fields to set….
- Expand the More list, and in Additional fields type the following formula:
{
"properties": [{
"key": "issue.templates.automation",
"value": {
"applyTemplate": "{{webhookData.templateKey}}",
"variables" : "{{webhookData.variables}}"
}
}]
}
- Complete the Rule details and click Save.
- Turn on the rule.
- Copy the URL from Incoming webhook rule.
Postman steps
- Click New and select Request.
- Type in the data.
- Click Save to Automation.
- Select the POST command from the list and enter copied Webhook URL.
- In Body section, paste the following formula, where the TemplateKey is the key of your Jira Template and Variables are taken from the Postman:
{
"templateKey": "PMT-602",
"variables": "{\"externalSystemName\":\"Postman\",\"externalSystemDescription\":\"Great tool to test REST API, cheers!\"}"
}
- Click Send.
- Refresh your Jira Project page.
Result
Issue has been created.
How to pass variables from external system to Automation?
We can pass variables from the webhook using smart values - inside {{ }} mark. We can use the webhookData object, which have access to the body of our webhook. Dot can be used to extract nested properties, however, the last element has to be a string or a number.
Check the following two examples on how to do it:
- Names of variables are constant
Webhook body:
{
"templateKey": "PMT-602",
"variables": {
"externalSystemName":"Postman",
"externalSystemDescription":"Great tool to test REST API, cheers!"
}
}
Additional fields in Automation:
{
"properties": [{
"key": "issue.templates.automation",
"value": {
"applyTemplate": "{{webhookData.templateKey}}"
"variables" : {
"externalSystemName": "{{webhookData.variables.externalSystemName}}",
"externalSystemDescription": "{{webhookData.variables.externalSystemDescription}}"
}
}
}]
}
- Names of variables can differ
If we don’t know the names of variables, or we want to use different templates and variables with single automation rule, we can’t fix it. Remember that all variables inside {{ }} mark need to be basic, i.e. string or number. We can’t pass object, therefore we will pass stringified JSON. Later, ITC will decode such string.
{
"properties": [{
"key": "issue.templates.automation",
"value": {
"applyTemplate": "{{webhookData.templateKey}}",
"variables" : "{{webhookData.variables}}"
}
}]
}
Additional fields in Automation:
{
"templateKey": "PMT-602",
"variables": "{\"externalSystemName\":\"Postman\",\"externalSystemDescription\":\"Great tool to test REST API, cheers!\"}"
}
If you’re interested in Advanced field editing in Automation, read the official Atlassian documentation.