Hi guys,
Before, I ve used not status changed after -8h to find issue where status has been not changed for 8. But now, I need it is 8 working hours (8h30 - 12h and 13h30 - 17h30)
Could u pls give me some advices
Thanks for your support
Hi @nhungttt148
First of all I have to say that answers might change according to the hosting type. Is this Datacenter or Cloud? Please tag the question accordingly.
Jira’s native JQL does not support complex work-hour calculations like this. You will need to use an app for this. As far as I know, Scriptrunner has custom scripts to define working hours and calculate the 8-hour delay within those ranges.
Hi @Tuncay Senturk _Snapbytes_
Thanks for your reply
We re using Datacenter (Jira Software). I intend to create an automation that can close issues when their status have not been changed after -8h (but for work-hours)
Pls tell me how to use script runner for this case?
Thank you so much
Hi @nhungttt148 , you can see that I have answers to all your prayers. For this specific problem, you can use this add on called JWME, it includes a feature that can set scheduled automations to check and change status of a workflow according to scripted conditions.
Below is my script for checking if more than 8 hours of working days has passed since a specific issue last updated
If you happen to sit next to a handsome and generous IT guy, you can ask him for configuring and testing this script. Or you can hire me directly, I takes every payment methods, including bubbles tea.
// return true if more than 8 hours of working days has passed since issue last updatedstrStartHour=" 8:30:00"strFinishHour=" 17:30:00"toMillis8h=8*60*60*1000dateTimeUpdated=issue.get("updated") //updated time with time//dateUpdated=dateTimeUpdated.clearTime() //clear time part of updatedstrUpdated=dateTimeUpdated.format("yyyy-MM-dd")dateUpdated= Date.parse("yyyy-MM-dd",strUpdated)updatedDayOfWeek=dateUpdated.day //get updated day of week, 0 =Sunday and so ondateTimeNow=new Date() // get current time and datestrNow=dateTimeNow.format("yyyy-MM-dd")dateNow= Date.parse("yyyy-MM-dd",strNow)strStartTimeOfUpdated=strUpdated+strStartHour // set start working hours of the date when issue is updateddateTimeStartTimeOfUpdated=Date.parse("yyyy-MM-dd HH:mm:ss",strStartTimeOfUpdated)strFinishTimeOfUpdated=strUpdated+strFinishHour // set start working hours of the date when issue is updateddateTimeFinishTimeOfUpdated=Date.parse("yyyy-MM-dd HH:mm:ss",strFinishTimeOfUpdated)strFinishTimeOfNow=strNow+strFinishHour // set finished working hours of the date when issue is updateddateTimeFinishTimeOfNow=Date.parse("yyyy-MM-dd HH:mm:ss",strFinishTimeOfNow)strStartTimeOfNow=strNow+strStartHourdateTimeStartTimeOfNow=Date.parse("yyyy-MM-dd HH:mm:ss",strStartTimeOfNow)elapsedWorkingDays= workdaysBetween(dateUpdated,dateNow)todayElapsedMillis=0updatedElapsedMillis=0if (elapsedWorkingDays>1){ todayElapsedMillis=toMillis8h updatedElapsedMillis=toMillis8h}//calculate elapsed milliselse if (elapsedWorkingDays==1){ //check if updated is a Saturday or Sunday, if it is, skip calculating elapsed hour of that day if (updatedDayOfWeek==0||updatedDayOfWeek==6) { //since it is 1 days elapsed since the issue updated, we only need to care about the elapsed time of that day from start hour dateTimeNow<=dateTimeStartTimeOfNow ? {todayElapsedMillis=0}: {todayElapsedMillis= dateTimeNow.getTime()-dateTimeStartTimeOfNow.getTime()} // if current time is after start hour, elapsed millis = current- start time, else elapsed millis=0 } //if updated is not a Sat or Sun and it's been 1 days since last updated, we need to calculate both of the time that elapsed in the updated date and the time elapsed of current date else { if (dateTimeUpdated>=dateTimeFinishTimeOfUpdated) { updatedElapsedMillis=0 } else updatedElapsedMillis=dateTimeFinishTimeOfUpdated.getTime()-dateTimeUpdated.getTime() if (dateTimeNow<=dateTimeStartTimeOfNow ) { todayElapsedMillis=0 } else todayElapsedMillis= dateTimeNow.getTime()-dateTimeStartTimeOfNow.getTime() // if updated time is after working hour of that day, then elapsed millis is 0, else, elapsed millis = finish time - updated }}else if (elapsedWorkingDays==0){ // if elapsed workingDays is 0 and updated is whether a Sat or Sun, elapsed time=0 if (updatedDayOfWeek==0||updatedDayOfWeek==6) { todayElapsedMillis=0 updatedElapsedMillis=0 } else { if(dateTimeUpdated>=dateTimeFinishTimeOfNow) { updatedElapsedMillis=0 } else updatedElapsedMillis=dateTimeFinishTimeOfNow.getTime()-dateTimeUpdated.getTime() }}totalElapsedMillis=todayElapsedMillis+updatedElapsedMillisif (totalElapsedMillis>=toMillis8h){ return true}else return false
It looks like you're new here. Sign in or register to get started.