Jira Automation - close an issue a set number of days after event
Asked by Sandy Greenberg:

I want to have a rule where an issue is automatically closed after it has a specific status for a set number of days.   

We get client queries that we raise as the Question issue type. After resolving we need to wait for client confirmation that an issue is sorted, so we're just now setting them to the status "Awaiting Customer". We are planning on closing them after three days if we get no response, but would like to automate it. Any ideas?  

So something like:   
When issue transitioned to "Awaiting Customer"

If no Changes to status after three days then close issue

Else do nothing


Answers:
author: Dam
body: Hi Sandy,

Its already a known topic here: <https://community.atlassian.com/t5/Jira-Service-Management/Is-it-possible-to-use-any-automation-to-close-tickets-after-3/qaq-p/1424284>

If you go down in this page, I like the approach of Harry Heathcote using Automation only (no SLA) or also Italo Qualisoni \[e-Core\] using Automation and JQL filter... for example:

```
status = Closed and updated < -3d
```

Cheers,  
Dam.

comments: author: Sandy Greenberg
body: Hi Dam, I think you replied as I was editing the question so I don't think that will work. We may be updating the issue within that three days and wouldn't want that to reset the clock. So it'd need to be "status not changed in 3 days" then close issue but I can't see that working in JQL.


author: Dam
body: aah :) in JQL you can do:

```
status = Closed AND NOT status CHANGED AFTER -3d
```

This is a valid JQL search, but I'm not 100% sure about the result cause I don't have the set of data to test this JQL but it should do the trick :)

Can you please try and let me know?

Cheers,  
Dam.


author: Dam
body: [@Sandy Greenberg](/t5/user/viewprofilepage/user-id/1152579) did you had a chance to try the JQL filter I suggested? :)


author: Sandy Greenberg
body: I just have now [@Dam](/t5/user/viewprofilepage/user-id/722152) as your comments came after I logged off for the day.

The JQL "status = xxxxxxx AND NOT status CHANGED AFTER -3d" certainly seems to work. I'll have to give it a try in my test project with the automation to see if the scheduler does what I need it to do.


author: Sandy Greenberg
body: Thinking about it [@Dam](/t5/user/viewprofilepage/user-id/722152) I still don't see the solution on that page working. If I use the automation to set a due date when I set the status to "Awaiting Customer" and then use that date to auto close it after a time period that JQL wouldn't pick up other changes in the issue. I need a query and automation that will only transition the issue if there were no changes at all to it in that three day period.


author: Dam
body: Humm I see... "no change at all during that 3 days period": this is quite hard to do in JQL...

The CHANGED operator can be used with the Assignee, Fix Version, Priority, Reporter, Resolution, and Status fields only.   
<https://support.atlassian.com/jira-software-cloud/docs/advanced-search-reference-jql-operators/#Advancedsearchingoperatorsreference-CHANGEDCHANGED>

I will think a bit more about that, but I'm afraid this is impossible to do [@Sandy Greenberg](/t5/user/viewprofilepage/user-id/1152579)

Dam.


author: Dam
body: You will need to use the Updated date field in the JQL... this field is updated every time an update is done on an issue. <https://support.atlassian.com/jira-software-cloud/docs/advanced-search-reference-jql-fields/#Updated>

So the JQL filter should be:

```
status = "Awaiting Customer" AND NOT status CHANGED AFTER -3d AND updated <= -3d
```

[@Sandy Greenberg](/t5/user/viewprofilepage/user-id/1152579) I want to find a solution :) it's an interesting usecase.

Let me know if this filter is working better or not...

Dam.


author: Olha Onofriichuk_SaaSJet
body: Hi, [@Sandy Greenberg](/t5/user/viewprofilepage/user-id/1152579)

I'll try to help you. If you want a rule where an issue is automatically closed after it has a specific status for a set number of days, you can install plugins that offer such an opportunity. For example, [SLA Time and Report for Jira](https://marketplace.atlassian.com/apps/1220741?utm_source=Atlassian_Community&utm_medium=referral&utm_campaign=Comment_Jira-Automation-close-an-issue-a-set-number-of-days-after-event_20220703) add-on and do the following steps:

1. Install the add-on
2. **Create SLA configuration:**   
   Create 24 hours Calendar  

   ![24h calendar.png](https://community.atlassian.com/t5/image/serverpage/image-id/204335i16C002F9E909964E/image-size/large?v=v2&px=999 "24h calendar.png")
3. Set Trigger-field - "Waiting for Customer"  
   ![waiting for customer.png](https://community.atlassian.com/t5/image/serverpage/image-id/204336iD6F08929B7022366/image-size/large?v=v2&px=999 "waiting for customer.png")
4. Set time goal = 72 hours = 3 days x 24 hours = 72  
   ![goals.png](https://community.atlassian.com/t5/image/serverpage/image-id/204337i6284A409D133CBAB/image-size/large?v=v2&px=999 "goals.png")
5. Set status change to Resolved   
   ![resolved.png](https://community.atlassian.com/t5/image/serverpage/image-id/204338i4E89F1DE3EB9EF32/image-size/large?v=v2&px=999 "resolved.png")

   *Don't forget to check your workflow.*   
   *You need to have the ability to move to Resolved if this status was chosen.*
6. Create a task and change status to Waiting for customer

   Wait until your time goal happens.

   After 72 hours the status will be changed automatically.

   ![finish.png](https://community.atlassian.com/t5/image/serverpage/image-id/204339i6CBFB005F0EC9814/image-size/large?v=v2&px=999 "finish.png")

I hope this is what you need.  

Also, this add-on is created by my SaaSJet team, so if you have any questions, I'm here to answer them.

Regards,  
Olha

comments: author: Sandy Greenberg
body: Thanks Olha for your help, but it's a big problem getting plugins approved and paid for by our Jira admin team. I need a solution that's "out of the box".