How do I copy Aggregate Original Estimate to another field?

Tanner Wortham
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.
July 5, 2012

Below are two links that tell the whole story. Below that is a quick synopsis of what I want to do. Any help will be appreciated!

My original question:

https://answers.atlassian.com/questions/66094/preserving-original-estimate

Once answered, I hit up Atlassian since I thought I ran across a bug:

https://support.atlassian.com/browse/JSP-131174

Synopsis

My goal is to copy the value of aggregate original estimate (AOE) from a new feature and save it to a custom field. I want to do so at a specified point in the workflow.

My avenues of approach thus far:

  • Use 'Misc Workflow Extension' plugin to copy AOE to a custom field of type numeric via a post function. Error. (See 2nd link for a screenshot.)
  • Use 'Misc Workflow Extension' plugin to copy AOE to a custom field of type Intervia (from KCF additional custom fields plugin) via a post function. Error. (Same as above.)
  • Search the answer boards to find someone doing the same. No results.
  • Search google to find someone doing the same. Nothing.
  • Cuss obsessively. Success!

For the love, HELP! :)

4 answers

1 accepted

2 votes
Answer accepted
Tanner Wortham
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.
February 11, 2013

Here's the code I created that I now use as a post-function and that copies the aggregate of original estimate to a custom field upon the proper workflow transition:

 

import com.atlassian.jira.ComponentManager
import org.apache.log4j.Category
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.event.type.EventDispatchOption

log.setLevel(org.apache.log4j.Level.WARN)

log.debug ("---- Start locked estimate ----")
Double myEstimate = 0
issue.getSubTaskObjects().each { task ->
	log.debug("our task: $task")
	def taskEstimate = task.getOriginalEstimate()
	if (taskEstimate != null) {
		myEstimate += task.getOriginalEstimate()
	}
	log.debug("summed estimate: $myEstimate")
}

IssueManager issueManager = ComponentAccessor.getIssueManager()
UserManager userManager = ComponentAccessor.getUserManager()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField lockedEstimate = customFieldManager.getCustomFieldObjectByName("Locked Estimate")
MutableIssue myIssue = issue

myIssue.setCustomFieldValue(lockedEstimate, myEstimate)
issueManager.updateIssue(userManager.getUser("automation"), myIssue, EventDispatchOption.ISSUE_UPDATED, false)
log.debug ("---- End locked estimate ----")

 

 

Vladimir Voitechovic December 1, 2014

Hello, Tanner, I have now the same problem. Could you please write me where your put this code above? Thanks a lot, Vladimir

Tanner Wortham
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.
December 2, 2014

I realized that I've cleaned up the code above so I've edited my answer with the latest. To use the script: 1. Install the Script Runner plugin. 2. Modify whatever workflow you wish to use the script in. 3. Go to post-function for the appropriate transition. 4. Add a new "Script Post-Function" post-function. 5. Copy and paste the above.

Andrew Morin
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.
December 12, 2014

Hi Tanner, I was going through the same process you did at the start of this thread. When I started getting error messages and investigating I came across this. I have successfully implemented this in a test project and I see that your script gets the sub-tasks OE and gives the AOE. I am not a developer so was going to ask how could I add any time that was entered in the OE field of the parent issue? We are using a custom issue type called Project. Also what custom field type did you end up using? (i used a number field in my testing.) One other question was did you somehow restrict the ability to edit the Locked Estimate field after it was populated? Thanks Andrew

Tanner Wortham
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.
December 15, 2014

> how could I add any time that was entered in the OE field of the parent issue? 1. install the script runner plugin. 2. place the code above on your JIRA server. bear in mind it may need to be edited to some degree. (line 27 comes to mind.) 3. create a post-function at the proper transition that uses the code using "Script Post-Function" 4. ensure your screens contain the proper custom field so the new field is viewable. > what custom field type did you end up using? Interval Field > did you somehow restrict the ability to edit the Locked Estimate field after it was populated yes. this field is part of the view screen and is not part of the edit screen. as such, the only way it gets populated or changed is through the custom code we have.

Raju Adluru February 20, 2015

Hi Tanner I have similar request- i want to copy value from custom field(number) to original estimate field, i am looking at above script, not sure which to modify, i see you have used "automation" as a user!! i want to put this script in transition, can you help me what to modify for my case, thanks for your help. Raju

Tanner Wortham
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.
February 20, 2015

the two values that you'll want to change are "automation" which is the user executing the code and "Locked Estimate" which is the custom field in which the summed estimate is stored. follow my 5 steps in a previous comment for how to implement this.

Raju Adluru February 20, 2015

Tanner, thanks for quick update, yes i got those 2 fields, my case is other way round, i want to copy custom field to Original estimate, let me modify code and see, how it goes, thanks

Tanner Wortham
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.
February 20, 2015

ahh ... now i understand. that's a bit different but not substantially so. if you have questions, your best bet will be submitting them as questions on this site. the more specific, the more help the group can be. :)

0 votes
Tanner Wortham
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.
July 10, 2012

atlassian's reply:

Hey Tanner,

I am sorry but the Original Estimate field does not simply store a numeric value and thus can not be copied out. I would recommend that you just ask your users to enter it twice. If you would like a cleaner solution than you may need a custom plugin to accomplish this. You can look into our API at: https://confluence.atlassian.com/display/JIRA/API+Documentation or you can get in touch with an Atlassian Expert: http://www.atlassian.com/resources/experts/ that may be able to assist you. Unfortunetly, custom plugins are outside of the Atlassian Support Offerings (http://www.atlassian.com/resources/experts/) and we can not assist you with developing this.

Let us know if there is anything else we can help you with.

Cheers,
Boris Berenberg
Atlassian Support - San Francisco
Enjoyed the support?! Tweet us! #atlassiansupport

0 votes
Tanner Wortham
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.
July 8, 2012

My intent:
I want to preserve the original estimate of a feature at a point in time in the workflow. I planned to do so by copying the summation of the original estimate to a custom field during the appropriate transition. I provided several screen shots of much of what I describe below.

Steps to reproduce:
1. Create a custom field called Locked Estimate of type Number.*
2. Create a post function during the appropriate transition that copies summation of original estimate to locked estimate.
3. Publish this new workflow feature.
4. Create a feature with 0 hour estimate and a sub-task with 2 hour estimate.
5. Advance this feature through the post-function.

  • to ensure it wasn't some kind of field type conflict, i also tried copying the value from summation of original estimate to Time Spent on the post function. I got the same result as described below.

What I expected:
I expected the value would be preserved in Locked Estimate.

What actually happened:
I received an error. You'll see it as a screenshot.

0 votes
Norman Abramovitz
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.
July 6, 2012

I tried to look at your support ticket, but I was not able to. Please summarize the behavior you saw and any response from Atlassian.

Suggest an answer

Log in or Sign up to answer