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.
The code isn't pretty, but it answers the question:
import com.atlassian.jira.ComponentManager import com.atlassian.jira.security.JiraAuthenticationContextImpl import com.atlassian.velocity.VelocityManager import com.atlassian.jira.config.properties.ApplicationPropertiesImpl import com.atlassian.jira.issue.fields.AggregateOriginalEstimateSystemField import com.atlassian.jira.issue.search.SearchProviderFactoryImpl import com.atlassian.jira.project.DefaultProjectFactory import com.atlassian.jira.permission.DefaultPermissionContextFactory import com.atlassian.jira.permission.PermissionTypeManager import com.atlassian.jira.permission.WorkflowPermissionFactory import com.atlassian.jira.security.ThreadLocalCachingPermissionManager import com.atlassian.jira.issue.util.AggregateTimeTrackingCalculatorFactoryImpl import com.atlassian.jira.issue.util.AggregateTimeTrackingBean import com.atlassian.jira.issue.util.IssueImplAggregateTimeTrackingCalculator import com.atlassian.jira.issue.fields.CustomFieldImpl import com.atlassian.jira.issue.managers.DefaultCustomFieldManager import com.atlassian.jira.issue.fields.CustomFieldImpl import com.atlassian.jira.issue.util.DefaultIssueChangeHolder import com.atlassian.jira.issue.fields.layout.field.DefaultFieldLayoutManager import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem import com.atlassian.jira.issue.ModifiedValue import com.atlassian.jira.template.velocity.DefaultVelocityTemplatingEngine // constructing objects for getting AOE value ComponentManager componentManager = ComponentManager.getInstance() JiraAuthenticationContextImpl jac = componentManager.getJiraAuthenticationContext() AggregateTimeTrackingCalculatorFactoryImpl attcfi = new AggregateTimeTrackingCalculatorFactoryImpl (jac,new SearchProviderFactoryImpl(),new ThreadLocalCachingPermissionManager (new WorkflowPermissionFactory(),componentManager.getPermissionContextFactory(), componentManager.getProjectFactory())) IssueImplAggregateTimeTrackingCalculator iiattc = new IssueImplAggregateTimeTrackingCalculator (jac,componentManager.getPermissionManager()) AggregateTimeTrackingBean bean = iiattc.getAggregates(issue) AggregateOriginalEstimateSystemField aoesf = new AggregateOriginalEstimateSystemField (new DefaultVelocityTemplatingEngine(componentManager.getVelocityManager(),componentManager.getApplicationProperties()),componentManager.getApplicationProperties(), jac,attcfi) /* AggregateOriginalEstimateSystemField aoesf = new AggregateOriginalEstimateSystemField (componentManager.getVelocityManager(),componentManager.getApplicationProperties(), jac,attcfi) */ CustomFieldImpl lockedEstimate = componentManager.getCustomFieldManager(). getCustomFieldObject(10305) // finally calculating the answer Long summedEstimate = aoesf.getAggregateDuration(bean) summedEstimate == null ? summedEstimate = 0 : summedEstimate lockedEstimate .updateValue (componentManager.getFieldLayoutManager().getFieldLayout(issue).getFieldLayoutItem(lockedEstimate), issue,new ModifiedValue(lockedEstimate.getValue(issue),summedEstimate as Double), new DefaultIssueChangeHolder()) return true
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.