Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hi i need to calculate the time the issues is in specific issue type using a scripted field.
any suggestion regarding this ?
Hi,
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.history.ChangeItemBean
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def inProgressName = "Bug"
List<Long> rt = [0L]
def changeItems = changeHistoryManager.getChangeItemsForField(issue, "issuetype")
changeItems.reverse().each {ChangeItemBean item ->
def timeDiff = System.currentTimeMillis() - item.created.getTime()
if (item.fromString == inProgressName) {
rt << -timeDiff
}
if (item.toString == inProgressName){
rt << timeDiff
}
}
def total = rt.sum() as Long
return (total / 1000) as long ?: 0L
And let me know if that solves the issue, please share the answer if already been resolved.
Regards,
Anzar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.