Hi All
I see in ScriptRunner that you can create a field to count how long the current problem has been in progress, but I have two problems when I configure it
When the problem is in its initial state, the field displays a value of null
I can't count the total time to multiple states
My code looks like this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.history.ChangeItemBean
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def inProgressName = "In Progress"
def test = "Resolved"
List<Long> rt = [0L]
def changeItems = changeHistoryManager.getChangeItemsForField(issue, "status")
changeItems.reverse().each { ChangeItemBean item ->
def timeDiff = System.currentTimeMillis() - item.created.getTime()
if (item.fromString == inProgressName) {
rt << -timeDiff
}
if (item.toString == test) {
rt << timeDiff
}
}
def total = rt.sum() as Long
(total / 1000) as long ?: 0L