Hi,
I would like to change get the last transition date, how do I change this script runner script to do this?
Many Thanks
Kevin
package com.onresolve.jira.groovy.test.scriptfields.scripts
import com.atlassian.jira.component.ComponentAccessor
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def created = changeHistoryManager.getChangeItemsForField(issue, "status").find {
it.toString == "Done"
}?.getCreated()
def createdTime = created?.getTime()
createdTime ? new Date(createdTime) : null
// can run this example of getting the time in ScriptRunner console
// https://${MY_SERVER}/jira/plugins/servlet/scriptrunner/admin/console
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
IssueManager issueManager = ComponentAccessor.issueManager
Issue issue = issueManager.getIssueObject("TEST-9999")
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def result = changeHistoryManager.getChangeItemsForField(issue, "status").find {
it.toString == "Done"
}?.getCreated().getTime()
log.debug(result)
I'd like to figure this one out to. The problem is this:
I can make a scripted field to capture the date the transition was executed, and I'm all set for new issues.
However, my user just asked to get this populated on existing issues, which means poking through history.
I assume I need to build an array here and look for the last instance, but perhaps there is some more elegant way to do this.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.