Forums

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

How do I reference Original Estimate via ChangeHistoryManager?

jordank
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 3, 2020

Hello,

I'm using ScriptRunner to write a Script Job that fires off a custom email report at the same time every night. I'm utilizing the ChangeHistoryManager to look for issues that had their status updated since the start of the day.

This works: 

changeHistoryManager.getChangeItemsForField(estimateUpdateResults.getIssues()[k], "status")

 But when I look for changed Original Estimates since the start of the day, I can't find a syntax that works. This doesn't work:

changeHistoryManager.getChangeItemsForField(estimateUpdateResults.getIssues()[k], "time_original_estimate")

Can anyone offer assistance or perhaps offer another solution for looking at the history of the Original Estimate field? It is not a field that supports history searches out of the box.

Thanks! 

1 answer

1 vote
PD Sheehan
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.
March 3, 2020

Hi @jordank 

I didn't know for sure ... and rather than just give you the answer .... let me share how I found out.

First I look at the available methods in ChangeHistoryManager.

I saw getChangeItemsWithFieldForIssues which returns a ChangeHistory. Looking at the list of methods for ChangeHistory, I saw changeItemBean which is the same class returned as getChangeItemsForField.

So I put all that together and ran this:

import com.atlassian.jira.component.ComponentAccessor
def im = ComponentAccessor.issueManager
def chm = ComponentAccessor.changeHistoryManager
def issue = im.getIssueObject('JSP-1922')

chm.getChangeItemsWithFieldsForIssues([issue],null).collect{
it.changeItemBeans.field
}

This showed me all the "field" values for all my changes on my issue. And since I had just changed the original estimate, the last value in the list was 'timeoriginalestimate'.

So I ran 

chm.getChangeItemsForField(issue, 'timeoriginalestimate')

And got the values that you'd expect.

Hope that helps.

Narelle Edwards July 19, 2020

Just wanted to say "thank you" to @PD Sheehan  I've been struggling with using these two ChangeHistoryManager functions - your response gave me exactly the examples I needed :-)

Like PD Sheehan likes this

Suggest an answer

Log in or Sign up to answer