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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 updated
strStartHour=" 8:30:00"
strFinishHour=" 17:30:00"
toMillis8h=8*60*60*1000
dateTimeUpdated=issue.get("updated") //updated time with time
//dateUpdated=dateTimeUpdated.clearTime() //clear time part of updated
strUpdated=dateTimeUpdated.format("yyyy-MM-dd")
dateUpdated= Date.parse("yyyy-MM-dd",strUpdated)
updatedDayOfWeek=dateUpdated.day //get updated day of week, 0 =Sunday and so on
dateTimeNow=new Date() // get current time and date
strNow=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 updated
dateTimeStartTimeOfUpdated=Date.parse("yyyy-MM-dd HH:mm:ss",strStartTimeOfUpdated)
strFinishTimeOfUpdated=strUpdated+strFinishHour // set start working hours of the date when issue is updated
dateTimeFinishTimeOfUpdated=Date.parse("yyyy-MM-dd HH:mm:ss",strFinishTimeOfUpdated)
strFinishTimeOfNow=strNow+strFinishHour // set finished working hours of the date when issue is updated
dateTimeFinishTimeOfNow=Date.parse("yyyy-MM-dd HH:mm:ss",strFinishTimeOfNow)
strStartTimeOfNow=strNow+strStartHour
dateTimeStartTimeOfNow=Date.parse("yyyy-MM-dd HH:mm:ss",strStartTimeOfNow)
elapsedWorkingDays= workdaysBetween(dateUpdated,dateNow)
todayElapsedMillis=0
updatedElapsedMillis=0
if (elapsedWorkingDays>1)
{
todayElapsedMillis=toMillis8h
updatedElapsedMillis=toMillis8h
}
//calculate elapsed millis
else 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+updatedElapsedMillis
if (totalElapsedMillis>=toMillis8h)
{
return true
}
else return false
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.