Automation for Jira - How to create a rule that counts the number of times an issue was transitioned to a status

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

This article explains how to create a rule that counts the number of times a Jira issue was transitioned to a specific status.

Solution

The solution consists of creating a custom field of type Number Field that will be incremented via an automation rule every time an issue enters a specific status.

1. Go to ⚙ > Issues > Custom Fields

2. Create a new custom field of type Number Field

Create a number field

3. During the creation of the field, you will need to configure its context. Make sure to include all the projects for which you need to configure the automation rule:

Select respective projects

4. After the custom field is created, click on ... > Configure next to it, check the URL box and pick up the custom field ID at the end of the URL as illustrated in the screenshot below:

Copy the customfield ID

5. For each project for which you need to create an automation rule, go to Project Settings > Automation, and create a new automation rule as follows:

  • WHEN: Issue transitioned

    • From: any status

    • To: Choose the status for which you need to count how many times the issue was transitioned to it

  • ACTION: Edit Issue:

    • Choose the custom field created earlier

    • Paste the following expression underneath this field, after replacing XXXXX with the ID of the custom field (obtained in an earlier step):

      1 {{#increment}}{{issue.customfield_XXXXX}}{{/}}
  • The automation rule will look like in the screenshot below:

Add Edit issue action

Updated on June 6, 2024

Still need help?

The Atlassian Community is here for you.