Program schedule for turning rules on and off
Asked by Valeria_Mejia:

Hi, I would like to know if you can help me with the following problem:  
I have created 3 rules to assign incidents in Jira, these 3 rules are the same in them the only difference is the list of people to which they will be assigned since they work in 3 different shifts in the day, now well the trigger should always be that the rule is executed when creating a new incident but is it possible that these rules are scheduled to turn on and off at different times of the day according to the shifts or only manually?


Answers:
author: Mikael Sandberg
body: The short answer is no, you cannot turn off and on an automation on a schedule, mainly because automation currently do not have an API. Instead of having three different automation to do this, have you considered using the create timestamp to determine who it should be assigned to?

If you do it based on the hour the request is created you would just have to create if/else conditions that checks the hour and assigned based on the defined list for that hour like this:

![Screenshot 2022-12-14 at 1.43.29 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/230506iBE7C4DF7055618F1/image-dimensions/192x596?v=v2 "Screenshot 2022-12-14 at 1.43.29 PM.png")

If you are on standard JSM or higher you also have access to on-call scheduling, and soon you will be able to use that schedule in automation, it is currently slated for Q1 2023 according to [Atlassian's public roadmap](https://www.atlassian.com/roadmap/cloud?status=future;comingSoon&search=automation). Once that is supported it will be a lot easier to maintain round-robin assignments.

comments: author: Valeria_Mejia
body: I really liked this form and if it works it would be a success.  
I added a few conditions to the rule and I want to do it with the current time of Costa Rica, currently the rule is like this but when testing and creating an issue is not assigned, I imagine it is because of the format of the hours.  
![2022-12-15_14h55_26.png](https://community.atlassian.com/t5/image/serverpage/image-id/230706i2C9DBA17B21EA7BD/image-size/large?v=v2&px=999 "2022-12-15_14h55_26.png")


author: Mikael Sandberg
body: If you look at the automation I have it logs the time both as UTC and PST. Jira saves all times as UTC, so you have to compensate for that. So for example in your rule when you want to trigger at 2:30 pm - 3:30 pm CST, you have to look for 20:30 - 21:30 UTC. And because you are using half hours too you would need to add that to your If compare.

I would recommend <https://www.worldtimebuddy.com/>, I used that when I was setting up our automation because we cover four different time zones.


author: Valeria_Mejia
body: Hey Mikael,  

I have been trying to configure the if to use the time and a half and have not figured out how to set it.

I should have a two-shift schedule for various sub groups of people I have tried the following ways but it hasn't worked

![2022-12-21_14h31_40.png](https://community.atlassian.com/t5/image/serverpage/image-id/231647i8F2A4920C7C62602/image-size/large?v=v2&px=999 "2022-12-21_14h31_40.png")![2022-12-21_13h38_56.png](https://community.atlassian.com/t5/image/serverpage/image-id/231646i3498332DF5C6BFA7/image-size/large?v=v2&px=999 "2022-12-21_13h38_56.png")


author: Mikael Sandberg
body: Because you want to do it on the half hour you would need to use regular expression to catch the full hour. Something like this should work:

![Screenshot 2022-12-21 at 2.43.24 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/231669iC029B30362924951/image-dimensions/237x544?v=v2 "Screenshot 2022-12-21 at 2.43.24 PM.png")


author: Mikael Sandberg
body: Note that I am using the {{time}} variable that is {{issue.created.format("h")}}:{{issue.created.format("m")}}, you could use {{issue.created}} but that also includes seconds and the date, so the regex would have to be a bit different.


author: Valeria_Mejia
body: I have been trying the way you have told me and also other ways and other regular expressions, but it does not recognize the hours at all and does not assign the incidents to the correct people in the shift, I really do not understand what is wrong.

Regular expressions tested:  
((9):(\[3-5\]\\d\\s)\|(10):(\[0-2\])\\d\\s)(AM\|PM) with {{issue.created.shortTime}}

((9):(\[3-5\]\\d\\s)\|(10):(\[0-2\])\\d\\s) with {{issue.created.shortTime}}

(9):(\[3-5\]\[0-9\]))\|((10):(\[0-2\]\[0-9\])\\s with{{issue.created.shortTime}}

/(10):\[3-5\]\\d\|(11):\[0-2\]\\d/g with {{issue.created.format("H")}}:{{issue.created.format("m")}}

(9):(\[3-5\]\[0-9\])\|((10):(\[0-2\]\[0-9\])) with {{issue.created.format("H")}}:{{issue.created.format("m")}}  
(9):(\[3-5\]\[0-9\]))\|((10):(\[0-2\]\[0-9\])\\s(PM) with {{issue.created.format("H")}}:{issue.created.format("m")}

}![2022-12-26_16h23_11.png](https://community.atlassian.com/t5/image/serverpage/image-id/232057i2AE7B8B325E99455/image-size/large?v=v2&px=999 "2022-12-26_16h23_11.png")![2022-12-26_16h32_41.png](https://community.atlassian.com/t5/image/serverpage/image-id/232055i04F7A32F3D0C2044/image-size/large?v=v2&px=999 "2022-12-26_16h32_41.png")