Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Need JQL for flagging requests that get created between specific hours on specific days.

Peter Hernandez February 25, 2022

Hello, we are trying to automate an "on-call" flag for our help desk, We have a custom field that will get changed when a ticket gets created between 5pm-7am Mon-Fri and any time on Sat and Sun. We have the following JQL in place. 

(created < startOfDay("+7h") OR created > startOfDay("+17h")) AND (issuetype not in ("Remote Access", "EUS - Equipment Checkout - Take Home")) AND project = EUS AND creator in membersOf("EUS Group") 

But we are having trouble adding in the Sat-Sun portion of it. Any help would be appreciated. 

Thanks!

 

2 answers

3 votes
Stefan Salzl
Community Champion
February 25, 2022

Hi @Peter Hernandez 

 

1. Saturday/Sunday

According to this documentation 

  • endOfWeek() --> Saturday
  • startOfWeek() --> Sunday

Guess this would go into your first part of the jql with something like 

...OR create in(endOfWeek(), startOfWeek())...

 

2. JQL/conditions (in case of automation rule)

I would suggest to check some conditions (that are easy to check) before the create date as they do not consist of 'OR' relation and the automation rule could immediatly stop processing (and processing throug JQL or date check) in case none of these conditions are met. (as I don´t have same issue types and user groups I just picked some that are available, in case of that automation rule the project doesn´t need to be checked as condition as the rule only exists in the related project and will only be triggered within)

image.png

 

Hope this is what you were looking for. Please let me know if this works.

Best
Stefan

2 votes
Radek Dostál
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.
February 25, 2022

I would probably try something like 'created > endOfWeek("-1d") AND created < endOfWeek("+1d")', refering to https://support.atlassian.com/jira-software-cloud/docs/advanced-search-reference-jql-functions/#Advancedsearchingfunctionsreference-endOfWeekendOfWeek--

 

But I think you have one part which doesn't work as you say it should:

created < startOfDay("+7h") OR created > startOfDay("+17h")

If I do this then it will show me every issue created in the history of the instance, because < startOfDay("+7h") means "anything before that and there is no historical limit, since everything is older than that".

 

So if I try to refine it in a way I think it should work, then I get to:

project = TEST AND ((created > startOfDay() AND created < startOfDay("+7h") OR created < endOfDay() AND created > startOfDay("+17h")) OR (created > endOfWeek("-1d") AND created < endOfWeek("+1d")))

 

But even then I would give this some thorough test and trial if it really works the way it should in practice. It seems to do it at least locally but I didn't test issues exactly 00:00 or 00:01 or 06:59 07:01 etc., so you might want to double check if it works on your instance as well.

 

As long as your automation reacts to issues on-time and on-demand (e.g. listener or automation rule), then this should theoretically work.. as long as there isn't delay.

If this were done with some scheduled job then that might be a problem since we cannot dynamically say "any day between 00:00 and 07:00 and any day between 17:00 and 23:59" right. So as long as this is reactive in time then yeah that might work, I think.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events