How to track the changes to a custom field based on the workflow status?

Chandana January 14, 2020

Hi, I wrote the below scripted field to track the number of changes to a field say 'Story Points'. 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.model.ChangeGroup
import com.atlassian.jira.model.ChangeItem
import com.atlassian.jira.issue.history.ChangeItemBean

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def changeItems = changeHistoryManager.getChangeItemsForField(issue,'Story Points')

if (changeItems) {

     return changeItems.size();

}
else{

return 0


}

This field is working as expected. i.e if the 'Story points' field is updated thrice then the scripted field will display '3' meaning the field has updated three times. 

However, now I am trying to track the changes only when a Story is not in 'Draft' or 'In review' status. 

For instance:

If the Story Points field is updated once when a Story is 'In Draft' status , twice during 'In Review' status and thrice during the 'In Progress' status then, the Scripted field should only display '3' instead of '6'. 

Any suggestions to achieve this?

1 answer

0 votes
Matt Doar
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 14, 2020

I think you'd have to get all the ChangeItems and interate over them, deducing what status the issue is in for each change in the Story Points

Suggest an answer

Log in or Sign up to answer