Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Create issue if not results exist for JQL using Jira automation

Brad Prusa January 22, 2025

I'd like to use automation to check if an issue does not match a specified JQL, and if there is not a match, then create an issue. 

project = FOO AND type = Task AND resolution = Unresolved AND labels not in (BAR)

This would result in zero matches because the ticket was resolved. Then automation would create another task. 

On a weekly basis we perform several routine tasks, if there is already a task then there is no need to have another task created before the current one is closed. 

2 answers

0 votes
Marcos Defina
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 22, 2025

Hi @Brad Prusa ,

I would try something in these lines: 

  1. Run Scheduled event as often as you want (ex: every 15 mins)
  2. Execute an If block with your JQL as first result
    1. If your JQL returns something, then do nothing, and the automation ends
    2. If your JQL returns nothing, then create a task - as you can see in the Else block

Screenshot 2025-01-23 001850.png

Hope it helps

Brad Prusa January 22, 2025

Thanks. I tried something similar for my version but get an error that block can't be empty. 

Screenshot 2025-01-22 at 3.31.43 PM.png

Marcos Defina
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 22, 2025

Add something silly there, like send an email to yourself, or if you find something even less impactful - that should work

Brad Prusa January 22, 2025

Hmm.... it's not working because there are no matches I think. 

For example:

1. The first When query finds 4 tasks that are open. 

2. Then it looks at those 4 tasks and sees that none of them have the label bar, so it sends an email. There are no remaining issues at this point for it to create a new task. 

0 votes
Trudy Claspill
Community Champion
January 22, 2025

Hello @Brad Prusa 

Welcome to the Atlassian community.

Have you already tried to create this automation rule? If so, please show us what you have so far and the details of each step.

What version of Jira Data Center are you using?

Brad Prusa January 22, 2025

Yes, I've tried many different ways: if statements, if related issues condition with none match JQL matching non condition. It seems the issue is because automation finds no results, so there isn't an action to take without a match.

It looks like we are using Jira Project Management v9.12.12

 Screenshot 2025-01-22 at 3.16.28 PM.png


Screenshot 2025-01-22 at 3.19.26 PM.png

Marcos Defina
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 22, 2025

I think you're in the right track, you just need to invert the logic to the else block - as jira works mostly on iteration over tasks, and don't naturally support querying "lack of tasks".

Try this same setup but in the else block, with something un-impactful such as log action in the if-true block

Brad Prusa January 22, 2025

I'm not following what you mean. I'm starting to think this isn't possible because if there are no matches, then nothing is triggered. 

Trudy Claspill
Community Champion
January 22, 2025

I recommend a different logic to the construction of the rule.

You can still use the Scheduled trigger, but don't include a JQL in it.

Screenshot 2025-01-22 at 4.34.27 PM.png

Follow that with a Lookup Issue action where you execute the JQL that would find the issue, if it existed.

Screenshot 2025-01-22 at 4.36.20 PM.png

Follow that with an Advanced Compare condition to see if the results of that Lookup Issues was 0 issues found.

Screenshot 2025-01-22 at 4.38.15 PM.png

And if that condition passes (0 matching issues found) then execute your Create Issues action. An issue will be created only if no matching issues were found.

Screenshot 2025-01-22 at 4.39.17 PM.png

 

Like # people like this

Suggest an answer

Log in or Sign up to answer