While transitioning an issue I need to scan its history for old status transisitons.
I use the following Groovy script to walk through the issue history/changes:
//issue = <provided by JMWE>
def statusChanges = ComponentAccessor.getChangeHistoryManager().getChangeItemsForField(issue, "status")
for( com.atlassian.jira.issue.history.ChangeItemBean changeStatus : statusChanges ) {
fromStatusId = changeStatus.getFrom()
toStatusId = changeStatus.getTo()
log.debug( "Status changed from " + fromStatusId + " to " + toStatusId )
}
issueKey = issue.getKey()
issueStatus = issue.getStatus().getSimpleStatus().getName()
issueStatusCategory = issue.getStatus().getStatusCategory().getKey()
log.debug( issueKey + " \"" + issueStatus + "\"(" + issueStatusCategory + ")" )
I will end-up receiving this:
DEBUG: Status changed from 10000 to 3
DEBUG: Status changed from 3 to 10000
DEBUG: DEMOB-1 "To Do"(new)
As you may have spotted, I also want to know the status category of the status as determined with the current status (not with ChangeItem).
I want the same output with the ChangeItem as with the "current status".
From the All Classes documentation, I only could find interfaces but nothing I can use to resolve an status id to a Status object.
How to resolve Status object from status id?
You can use the com.atlassian.jira.config.ConstantsManager#getStatusObject method:
ComponentAccessor.getConstantsManager().getStatusObject(statusIdAsString).getStatusCategory().getKey()
Ok, I did not expect Status would go with constants. Thank you!
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.