Apps documentation
Issue Templates for Jira
Cloud Server/Data Center
Issue Templates for Jira

Cloud

Server/Data Center

Documentation
FAQ
Release notes
Articles & Videos
Last updated May 15, 2023

Automation

This chapter provides information on how to use Automation and Issue Templates together.

Combining Jira Automation and Issue Template for Jira requires using Automation’s Create Issue action and a custom issue.templates.automation property. You can delegate the job of creating the issue with Automation and apply a template right after the issue has been created with Issue Templates for Jira.

See Atlassian documentation to learn how to Create an issue with Automation.

Steps

  1. Configure the action to create an issue with all the required fields for the particular issue type you want to use.
  2. Expand More options, paste the function below and change TEMPLATE-1 to your template key:
{
    "properties": [{
        "key": "issue.templates.automation",
        "value": {
            "applyTemplate": "TEMPLATE-1"
        }
    }]
}
Example
Jira Issue Templates - Template Details: Automation
Issue Templates for Jira - Template Details: Automation

Result

This function instructs Issue Templates for Jira to applyTemplate with the issue key equal to TEMPLATE-1.

There are numerous triggers that you can use with the Create issue action and apply the template property. You can see some examples in the videos below.

Warning
Remember to change the Actor of the rule while configuring automation 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.
Note
Apply template action is executed right after creating an issue by Automation.

How to schedule creation of issues from templates using Jira Automation?

One of available options to create an issue from a template is to use Automation’s Scheduled trigger with Create issue action. Applying a template to a newly created issue is possible only if you change Create issue action’s properties, as shown in the example below:

{
    "properties": [{
        "key": "issue.templates.automation",
        "value": {
            "applyTemplate": "TEMPLATE-1"
        }
    }]
}

TEMPLATE-1 is a template key.

How to trigger creating issues from template from external tool?

The following example presents required steps in Jira Automation and an external tool (Postman in this case) to create issues from a template.

Jira Automation steps

  1. Create a template in Template Repository. Use {{ }} to set variables.
    Note
    By default, variables use [ ]. Read more about variables.
  2. Navigate to Project settings > Automation.
  3. Click Create rule.
  4. In New trigger, select Incoming webhook.
  5. In Execute this automation rule with select No issue from the webhook.
  6. Click Save.
  7. In Add component, click New action > Create issue.
  8. Select:
  • Project
  • Issue type
  • Choose fields to set (for example: Epic Name).
  1. Type the Summary and complete fields selected in Choose fields to set….
  2. Expand the More list, and in Additional fields type the following formula:
{
    "properties": [{
        "key": "issue.templates.automation", 
        "value": { 
            "applyTemplate": "{{webhookData.templateKey}}",
            "variables" : "{{webhookData.variables}}"
        }
    }]
}
  1. Complete the Rule details and click Save.
  2. Turn on the rule.
  3. Copy the URL from Incoming webhook rule.

Postman steps

  1. Click New and select Request.
  2. Type in data.
  3. Click Save to Automation.
  4. Select the POST command from the list and enter copied Webhook URL.
  5. In the 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!\"}"  
}
  1. Click Send.
  2. Refresh your Jira Project page.

Result

The issue has been created.

How to pass variables from external system to Automation?

You can pass variables from the webhook using smart values - inside {{ }}. Use a webhookData object, which has access to the body of the webhook. Dot can be used to extract nested properties, however, the last element has to be a string or a number.

See the two following examples:

  • 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

Remember that all variables inside {{ }} need to be basic, for example, a string or a number. You can’t pass an object, therefore it will pass stringified JSON. Issue Templates for Jira will decode such a 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!\"}"
}
Warning

For date variables use the supported ISO 8601 format.

Example:

2023-11-10

2023-11-10T11:00

2023-11-10T11:00+0100

Note
You can encode any JSON, by executing JSON.stringify(yourJsonObject) in the browser console or any other tool.

If you’re interested in Advanced field editing in Automation, read the official Atlassian documentation.