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
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.