Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to resolve Status object from status id?

soerenkornetzki February 6, 2018

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?

1 answer

1 accepted

1 vote
Answer accepted
David Fischer
Community Champion
February 6, 2018

You can use the com.atlassian.jira.config.ConstantsManager#getStatusObject method:

ComponentAccessor.getConstantsManager().getStatusObject(statusIdAsString).getStatusCategory().getKey()
soerenkornetzki February 6, 2018

Ok, I did not expect Status would go with constants. Thank you!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events