API get transitions using getChangeItemsWithFieldsForIssues

Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 10, 2018

I am working on a plugin and trying to get a list of transitions for an issue.

I was thinking to look through the change history for changes to status using the title method in code below

List<Issue> issues = new ArrayList();

issues.add(currentIssue);

List<String> fields = new ArrayList();

fields.add("status");

List<ChangeHistory> transHist = chgManager.getChangeItemsWithFieldsForIssues(issues, fields);

for (ChangeHistory change : transHist) {

UserHistoryEvent event = new UserHistoryEvent(change.getAuthorDisplayName(), change.getTimePerformed(),

"Transition", change.getId());

List<ChangeItemBean> cha = change.getChangeItemBeans();

 

events.add(event);

}

I am getting all change histories returned (3 in test) although only one amends status.

When I look for change items in debug the ChangeItemBean list is empty.

Am I missing a trick? Is there an easier method to get a list of issue transitions?

Tom

2 answers

1 accepted

0 votes
Answer accepted
Mark Markov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 10, 2018

Hello @Tom Lister

History doesn't contain information about transitions. Only status changes.

I made little research and it seems you cannot do it with Java API.

Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 10, 2018

I agree, there is no managed API methods that I can find. I am assuming that the status is only normally changed by workflow and can find those events in the history. Although they can be mixed in with other transition form changes as well.

in the Issue Activity tab you can see events reported as transitions

e.g.

Screen Shot 2018-10-10 at 15.15.37.png

I think I'll need to download the JIRA source and see where that comes from.

0 votes
Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 10, 2018

As an update, what I am seeing in debug is that I will get all the change histories for an issue, but if I look through the ChangeItem list, only the status change value is ever returned.

My comment about no items returned at all must have been fat fingers somewhere.

However this does seem to mean I have to iterate through all histories checking for items.

Suggest an answer

Log in or Sign up to answer