Assigning tickets depending of the hour of the day

Manuel Maldonado April 15, 2021

Hi, in my Service Project I have two teams, one of them manages the issues created during the day time (until 17h CEST) and the other one manages the issues created during the nigh time (from 17h CEST).

 

I'm trying to automate the assignment process but I'm not being able to find a condition matching my criteria, I tried something like a JQL query as this one:

{{(now.plusHours(7).jiraDate).compareTo(now.plusDays(1).jiraDate)}} = 0

It doesn't work at all, but I'm trying to add 7 hours to now in order to compare it with tomorrow, if now+7 = tomorrow, it means that now is after 17h. I don't know if it is the best way to do it (I guess it is not), but I've not been able to find any doc to help me.

 

Best regards.

2 answers

2 accepted

2 votes
Answer accepted
Bill Sheboy
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.
April 15, 2021

Hi @Manuel Maldonado  -- Welcome to the Atlassian Community!

You can also do this with an advanced compare and regular expression check.  Please see this post for details:

https://community.atlassian.com/t5/Automation-questions/Assigning-round-robin-according-to-the-hour-of-the-day/qaq-p/1651142

 

Best regards,

Bill

Manuel Maldonado April 16, 2021

Hi @Bill Sheboy, your solution worked great, you just need to take into account that "Created" value in a JQL is always at GTM timezone. This is how it turned out:

 

Captura de pantalla 2021-04-16 a las 11.08.39.png

 

Thanks so much! 

Like Bill Sheboy likes this
Bill Sheboy
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.
April 16, 2021

I am glad to hear that worked!

The way we solve the time zone issue is to adjust it before the condition test, rather than hard-code the altered time values.  That prevents issues with time changes for DST and data entry errors. 

For example:

{{issue.created.convertToTimeZone(issue.reporter.timeZone).format("hh")}}

Like Hana Kučerová likes this
BrentBot_ August 10, 2021

@Manuel Maldonado can you send me screenshots of your solution. I did the same but seems only my AM shift is working. @Bill any help would be appreciated.

Use case: the am clock will assign to custom field 1 on an issue type. the pm clock will assign to custom field 2 on an issue type

Capture1.PNGCapture.PNG

Bill Sheboy
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.
August 11, 2021

Hi @BrentBot_ 

For something like this, please consider using one rule (not two) and an if/else condition to handle the two cases. 

The reason to do this: Your regular expressions overlap.  The tests for "1" and "2" in the AM-condition could be found inside of the PM-condition values, and so if the AM rule runs first it will "win".  If you perform both in one rule, testing for the PM-condition first, I believe this will work as expected.

Best regards,
Bill

BrentBot_ August 11, 2021

thank you @Bill!!

BrentBot_ August 11, 2021

@Bill Sheboy I have created an if/then but the AM is still winning. what am i doing wrong?Capture.PNG

Bill Sheboy
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.
August 12, 2021

Before your if/else clause, please add a write to the audit log for the value you are checking:

{{issue.updated.convertToTimeZone(issue.reporter.timeZone).format("hh")}}

And perhaps also log this value too (please note the format change):

{{issue.updated.convertToTimeZone(issue.reporter.timeZone).format("H")}}

I recall when I last tried this, the automation implementation did not seem to match this documentation, so reviewing different formats could help.

Then run your test again and check the audit log to see what value is there.  That may reveal why it is matching on a value that you do not expect.

1 vote
Answer accepted
Hana Kučerová
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 15, 2021

Hi @Manuel Maldonado

welcome to the Atlassian Community!

I believe you can use JQL condition for this, something like:

created >= startOfDay(9h) AND created <= startOfDay(17h)

 If issue is created between 9 AM and 5 PM, then ...

Manuel Maldonado April 16, 2021

Hi @Hana Kučerová thanks so much for your solution, I I didn't get it to work but I think it was because of the timezone, as my test were done assuming that the dates would be at CEST and they are actually at GTM.

 

However, I finally took @Bill Sheboy solution and (after noticing it was failing because of the timezone) it worked!

 

Thanks so much anyway!

Like Hana Kučerová likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events