How to create a loop using JIRA automation
Asked by Reb Bravo:

Hi,

We are currently making a 3-strike rule automation using JIRA we have successfully created the first 3-strike notification. The rule condition is that if the ticket has been assigned to the Waiting for customer status, it will add a comment on the ticket and add a label corresponding to the strike.

* 1st strike - 7 days
* 2nd strike - 14 days
* 3rds strike - 21 days
* Ticket Closure - 22 days (add 24 hrs from the last notification)

![1st loop.png](/t5/image/serverpage/image-id/310773iDCE02E2B57CCA79F/image-size/large?v=v2&px=999 "1st loop.png")

Once the customer replies then a label will be added to the ticket "reset_3strike" which will trigger the loop we created.

We added a loop by creating another automation with different comment. (Please take note that we ticked the "Prevent duplicates by only adding this comment once to a particular issue.")

![2nd loop.png](/t5/image/serverpage/image-id/310777i73134642C6FEBFF8/image-size/large?v=v2&px=999 "2nd loop.png")

We would like to know if there is a way we could loop the notification for the 3 strike rule without creating an additional automation. For example if the automation reads the "reset_3strike" label it will run the 3-strike automation again and will comment the same notification again although there is already a similar comment on the ticket.

We have tried to un-tick the Prevent duplicates and it flooded the ticket with multiple comments.


Answers:
author: Walter Buggenhout
body: Hi [@Reb Bravo](/t5/user/viewprofilepage/user-id/5416507),

This is a creative approach, but you might be over-engineering it slightly.

When a ticket is in status *waiting for customer* and the customer replies, rather than adding a label, I would remove any *strike* labels entirely and change the issue status, since it is no longer *waiting for customer*.

When a ticket enters the waiting for customer status (for the first time or again), it will always get there with the same state: without any strike labels.

You can use a scheduled trigger and JQL fiilters to run this automation e.g. once a day. Having separate rules for the different scenarios does not need to be a problem, as they will only count to your automation rule execution limit if they perform any actions.

As an example:

```
status = "waiting for customer" and status changed to "waiting for customer"
before -7d and labels not in 'strike1'
```

this would retrieve all the issues you need to add the first comment to and add the label for. Using a filter will also process all issues in one go. You can use variants for the other scenarios in the list.

Hope this helps!

comments: author: Reb Bravo
body: Hi [@Walter Buggenhout](/t5/user/viewprofilepage/user-id/783225)

Works like a charm! This is perfect for our automation. Thank you so much!

Cheers,

Reb


author: Reb Bravo
body: Hi [@Walter Buggenhout](/t5/user/viewprofilepage/user-id/783225)

Good day! Additional question for the automation. Since we are running the 3 strike rule, we're currently sending proactive follow-up messages to our clients at 7-day intervals.

However, we've encountered an issue where these messages are still being sent out on weekends.

Is there a way for us to exclude weekends from the counting process? For instance, if the 7th-day falls on a Saturday, we'd like to skip that day and send the follow-up message on the next business day, which would be Monday. Is this possible?

For your reference, here are the JQL queries we are using.

* **1st Strike :**   
  project = "ESD" AND status = "Waiting for customer" AND (labels is EMPTY OR NOT (labels = "1st_strike" OR labels = "hold_3strike")) AND "Customer Request Type" != "UAT Feedback (ESD)" AND (assignee in membersOf(product-support) OR assignee in (712020:459e9b3a-2572-41f9-a936-0de543d66153, 712020:0ed0ea96-04b3-4fcf-950f-3751ad639a37, 712020:624e71285f63fd0069b70286)) AND **++not status changed after -7d++**   
* **2nd Strike :** project = "ESD" AND status = "Waiting for customer" AND (labels is EMPTY OR NOT (labels = "2nd_strike" OR labels = "hold_3strike")) AND "Customer Request Type" != "UAT Feedback (ESD)" AND (assignee in membersOf(product-support) OR assignee in (712020:459e9b3a-2572-41f9-a936-0de543d66153, 712020:0ed0ea96-04b3-4fcf-950f-3751ad639a37, 712020:624e71285f63fd0069b70286)) AND ++**not status changed after -14d**++
* **3rd Strike :** project = "ESD" AND status = "Waiting for customer" AND (labels is EMPTY OR NOT (labels = "3rd_strike" OR labels = "hold_3strike")) AND "Customer Request Type" != "UAT Feedback (ESD)" AND (assignee in membersOf(product-support) OR assignee in (712020:459e9b3a-2572-41f9-a936-0de543d66153, 712020:0ed0ea96-04b3-4fcf-950f-3751ad639a37, 712020:624e71285f63fd0069b70286)) AND ++**not status changed after -20d**++

Thank you in advance for your help!

Cheers,

Reb


author: Reb Bravo
body: Hi [@Walter Buggenhout](/t5/user/viewprofilepage/user-id/783225)

Good day! Just to follow up on my last comment is there a possible way we can exclude the weekends on the day counting?

Your answer will be greatly appreciated.

Thank you!


author: Walter Buggenhout
body: Hi [@Reb Bravo](/t5/user/viewprofilepage/user-id/5416507),

Well ... not the way you are currently approaching it. JQL just counts days, it does not have a feature to count business days.

If you would change your approach again and set up SLA's for this, you could use the SLA calendar to define working days and the SLA status and timer to steer your entire setup. It's possible, but it would be like starting all over again.

In addition: it seems that your cadence is based on weeks. 7 / 14 /21 days is 1 /2 / 3 weeks, so it's safe to assume that there will *always* be weekends in your current configuration. If you just add the weekend days to your math, you should automatically cover for them as non working days. So just increasing the counters to 9 / 18 / 27 days should come very close to the desired scenario, I guess.


Tags: cloud

jira-service-management

jira-service-management-cloud