Jira Automation: Exact Time in Status
Asked by Akash Panchal:

Hey everyone,

I'm looking to create the following Jira automation:

- When any ticket is in the status "I'm Open" for exactly 40 minutes, automatically create a ticket

I understand the automation part of it, just having trouble writing a JQL query. Here's what worked for me on first attempt:

project = "XYZ" AND status = "I'm Open" AND status CHANGED BEFORE -40m

The above query within the automation rule created the ticket automatically on first attempt, but when I tested it again it won't create additional tickets automatically. I'm assuming this is because it recognizes more than one ticket over time through that JQL query, thus, not following through with the automation.

Below is a similar JQL query I created that works as well, but is for issues that are greater than or equal to 40minutes:

project = "XYZ" AND NOT status CHANGED AFTER -40m AND status = "I'm Open"

++**In short, I'm simply looking for a way to modify one of the JQL queries above to grab an EXACT time (i.e. =40m). I've read that JQL cannot grab exact times, but is there a work around via automation that could do this?**++

Thanks for the help!!


Answers:
author: David Leal
body: Would you share your rule? how do you plan to trigger the rule, Since your scale is minutes, do you mean to schedule the run on every minute? I don't think it is possible. The minimum is 5 mins, and you would lose tickets since you are looking for exactly 40 minutes.

comments: author: Akash Panchal
body: [@David Leal](/t5/user/viewprofilepage/user-id/1567948) Thanks for the response, here is an example of the automation rule below:  

![Screenshot 2023-09-11 165151.png](https://community.atlassian.com/t5/image/serverpage/image-id/280007iABD3EF340A80F150/image-size/large?v=v2&px=999 "Screenshot 2023-09-11 165151.png")


author: Akash Panchal
body: [@David Leal](/t5/user/viewprofilepage/user-id/1567948) Essentially:

When an issue is in the *I'm Open* status for 40minutes, create a *General* issue ticket within project *ITS*automatically.


author: David Leal
body: [@Akash Panchal](/t5/user/viewprofilepage/user-id/5277734) I don't think you are going to achieve what you want. The trigger condition is on real time, then the JQL will apply to all the universe of issue that satisfy the condition, not a condition for the triggered issue. I would say there are two issues here:

1. The trigger condition, should not base on issue transitioned (you are looking for something that happened in the past), you would need a rule that is triggered based on schedule, but you have a minimum threshold of 5 minutes, as per my understanding.

2. Because of the threshold of the previous item, you cannot find exact -40 minutes, but rather a range.

I would suggest to create a rule based on schedule of 5 mins, which is not too much efficient, because the rule will run every 5 minutes, then check for a condition based on field status Status Category change for the condition.

For example:![Screenshot 2023-09-11 at 6.32.56 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/280016iD69622AECC27299D/image-size/large?v=v2&px=999 "Screenshot 2023-09-11 at 6.32.56 PM.png")

then

![Screenshot 2023-09-11 at 6.33.15 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/280017i24E578DEBCBF7387/image-size/large?v=v2&px=999 "Screenshot 2023-09-11 at 6.33.15 PM.png")

You need in some how to be able to not take into account issues that already were processed through the previous call of the JQL, otherwise every time it will be triggered again. For example to add a label when the issue match the condition. For example: PROCESSED or something like that, so next time it doesn't appear in your query. You would need to modify the query to include also issues where the label is not present, for example labels not in (PROCESSED).

Since the rule will run every 5 minutes you will have a threshold of 5 minutes, not exactly 40 minutes.

I think you can put the condition in JQL this way too:

```
status in ("IN PROGRESS") AND statusCategoryChangedDate <= -40m AND statusCategoryChangedDate >= -45m
```

I guess you get the idea, so you can adjust it to your specific scenario.

David


author: Akash Panchal
body: [@David Leal](/t5/user/viewprofilepage/user-id/1567948) Sorry for the late response, your guidance above helped me create this scheduled automation rule! The missing pieces for me were using scheduled automation and updating the label system field once an automation rule has been executed.

Thank you!