Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Count total issues with same category then compare against a custom field - Automation for Jira

Hey there community!

Use case:
We are working on an incident process in our jira instance to automatically create a Master Incident ticket when the total number of jira issues with a particular category in JQL search matches a certain value in another custom field.

For example:

Category: System Outage

Category outage value: i.e. 10 (meaning declare an incident if there 10 issues created over the course of n hours)

If 10 jira issues are created or updated and contain the category 'System Outage' then we want to jira to automatically create a Master Incident issue and link all 10 issues to it.


What is the best approach you would recommend for automating such a thing?

Automation for Jira doesn't seem powerful enough for our needs as the automations run on each issue found in the JQL rather than running an action if the total search results > n (i.e. 10)

Ideally we are looking for Jira (api/script?) to run and count number of open issues (total results perhaps?) with a particular category and then compare the results with the category outage value. If search results >= outage value then create master incident ticket.

Would be great to hear if anyone has done something similar? 

All advice much appreciated!!



2 answers

4 votes
Mykenna Cepek Community Leader Oct 21, 2020

I wasn't sure it could be done with Automation for Jira, but I think I found something that might work for you. I like a challenge!

Here was the test rule I created:

Screen Shot 2020-10-21 at 10.46.03 AM.png

I started with a Scheduled trigger. This avoids the rule being scoped to just one triggering issue. I believe you'll have to run this on a schedule (e.g. once an hour, every 10 minutes, whatever), since any other trigger type will reduce the scope.

Next I used the Lookup Issues action, which was able to execute the JQL globally (outside the scope of a triggered issue). Note that this action has a limit of 100 issues, but since your use-case was in the range of 10 issues, it should work for this.

The compare conditional checks to ensure there were enough results to continue. I used a limit of "greater than 2" for my test. You'd use "greater than 9", since there is no "greater than or equal to 10" option.

The branch/loop repeated the JQL, iterating on a simple Audit Log entry, just to show that it found all the target issues. In my test, three matching issues were noted in the Audit Log:

Screen Shot 2020-10-21 at 10.55.06 AM.png

It is unfortunate that the same JQL needs to be executed twice. You'll probably want to balance the frequency of execution against that overhead. And it's a bit brittle, as both JQL queries have to be kept in sync. However, I think it accomplishes your goal.

Here are a few pointers to related articles and documentation:

I hope that helps!

Thanks so much for taking the time to run through that @Mykenna Cepek

Sadly we are on a server instance (apologies I should've mentioned that at the beginning :facepalm:) so we are missing the lookup functionality that could prove useful for our use case. 

Not expecting that feature to make it across to server anytime soon based on the recent Atlassian news :)

Appreciate your input with it but I have a feeling that we may need to look at other options

Mykenna Cepek Community Leader Oct 22, 2020

4jfqxs.jpgUnderstood - best wishes, @Daniel Smith !

Like John M Funk likes this

I had a similar need and am working with the cloud version. Your example helped tremendously! @Mykenna Cepek 

Like Mykenna Cepek likes this

Hi @Daniel Smith ,

what you need can be done via API but I don't know if that's efficient.

1. To check how many issues are created in a given time period you can use GET request to Jira REST API (with no fields in response, just their count)

2. Comparison value triggers script to create issue (POST) with particular attributes.

Set above tool to run every 5 minutes (or so) and that's it.

As I said, I don't know if that's efficient. Checking number of issues is pretty light when no fields are sent back to user.




Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

Marketplace Partner Spotlight: AppLiger

This month the spotlight is on AppLiger. We caught up with Pavel Pavlovsky, CEO and Product Manager, to learn how the company started and what fuels the team's creativity.    Atlassian:...

397 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you