JIRA Automation: Get the count of selected issues
Asked by Johannes Fuenger:

Hi out there,  

I am not able to figure out how to set up an automation rule with the following functionality  

- On a regular basis a field X of all issues of a dedicated issue type A shall be updated.  
- the field X shall contain the number of issues of an issue type B where a field Y of B ,matches a field Z of A  

May you help to give me at hint? I am still quite new to JIRA and struggeling around to get the funcionality implemented. Any help is highly appreciated.  

Regards  

Johannes


Answers:
author: Bill Sheboy
body: Hi [@Johannes Fuenger](/t5/user/viewprofilepage/user-id/5470373)

First thing, I recommend pausing to review some of the automation documentation. That will help you when creating a rule. To get you started on creating your rule, please refer to these documentation and example sources:

* <https://www.atlassian.com/software/jira/guides/automation/overview#what-is-automation>
* [https://www.atlassian.com/software/jira/automation-template-library#/rule-list?systemLabelId=all\&page=1\&pageSize=20\&sortKey=name\&sortOrder=ASC](https://www.atlassian.com/software/jira/automation-template-library#/rule-list?systemLabelId=all&page=1&pageSize=20&sortKey=name&sortOrder=ASC)
* <https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/>
* <https://support.atlassian.com/jira-software-cloud/docs/use-advanced-search-with-jira-query-language-jql/>

Next, I recommend clarifying your scenario by noting an example issue and writing the JQL needed to find the related issues (between types A and B).

Then pause and explain that scenario to another team member. That will clarify your understanding of the problem and help to refine the needed rule steps.

Then when you write your rule, it will likely use as Scheduled Trigger with your JQL to find the first set of issues, and the Lookup Issues action to find the others. The count of issues might be {{lookupIssues.size\|0}} based on that lookup result.

Kind regards,  
Bill

comments: author: Johannes Fuenger
body: Hi Bill,  
thanks for your hints and recommendation.  

I used already {{Lookupissues}} and it worked. But in some cases I have \>20.000 (twenty thousand) of related issues. In these cases I do not get the right count, because is reaches the limits set by the dba.  

regards  

Johannes


author: Johannes Fuenger
body: Bill,  
the relevant Issues are linked as well, so I may use {{issuelinks.size}}. Is it possoble to get the number of links of a specific link type.   
regards  
Johannes


author: Bill Sheboy
body: Thanks for that additional information, Johannes.

With that many issues, you will not be able to easily get the counts. Jira triggers, branches, and lookup issues are limited in the number that can be returned / processed: <https://support.atlassian.com/cloud-automation/docs/automation-service-limits/>

Instead the rule could use the Send Web Request action to call the REST API issue search with JQL. Even though all issues would not be returned, the matching count of issues would be included. Please look here if you want to try that: <https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828>

Regarding issue links, you are correct that the issue links can be counted with that smart value. As linked issues are dynamically loaded in automation rules, I do not now what happens for {{issue.issuelinks.size}} if there are over the service limit counts.


author: Johannes Fuenger
body: Bill,  

thanks for your support, great!!  

Further question: Is it possible to get the issuelinks.size per link type.?  

Regards  
Johannes  

<br />


author: Bill Sheboy
body: Yes, that is possible.

You may test the issueLinkType with your JQL used to gather the issues, and then count them: <https://support.atlassian.com/jira-software-cloud/docs/jql-fields/#Issue-link-type>

Please note well: many link types have direction, such as "blocks" versus "is blocked by". So check your specific link for the ones you want to count.


author: Johannes Fuenger
body: thanks


Tags: cloud