It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you