Automation For Jira - How to create a rule that counts the number of sub-tasks that belong to an issue

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

Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles 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 describes how to create an Automation Rule using the Lookup Issues action available in Automation for Jira from the version 9.0.1, which will perform the following actions:

  • Calculate the number of sub-tasks that belong to a Jira issue
  • Add this value to a number field in the issue

Environment

  • Jira Data Center Only (This article does not apply to Jira Server licenses)
  • Applicable Jira / A4J (Automation for Jira) versions:
    • Jira 9.11.0 and any higher version (this Jira version ships with A4J 9.0.1)
    • OR Jira 8.20.0 and any higher version, in combination with A4J 9.0.1

Solution

Preliminary step

Create a new custom field of number type via the page ⚙ > Issues > Custom Fields.

Rule configuration

The rule can be configured as follows:

  • Trigger: "Scheduled", with the parameters below:
    • Rate: every 10min
    • JQL: copy the JQL used by the gadget filter
    • Untick the option Only include issues that have changed since the last time this rule executed
  • Action: "Lookup Issues", with the parameter below:
    • JQL:
      parent = {{triggerIssue.key}}
  • Action: "Edit Issue", with the parameters below:
    • Select the Custom Number Field in the list of fields to edit
    • Copy the syntax below:
      {{lookupIssues.size}}

Screenshot showing the rule


Last modified on Jan 3, 2025

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.