Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Cannot update estimate on an issue when using clone and link

Jo-André Lia March 15, 2017

Hi,
I'm trying to use the Clone and link functionality from ScriptRunner and in the process updating the new ticket a bit using the Additional issue actions field.
I'm setting the estimate field on the issue, but it doesn't stick. After the issue has been created it does not have the new value. It has the same value as the ticket it is cloned from.

I have added this code:

import com.atlassian.jira.bc.project.component.ProjectComponent
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.project.version.Version
import com.atlassian.jira.project.version.VersionManager

MutableIssue currentIssue = issue
BigDecimal timeSpent = getTimeSpent(sourceIssue)
log.warn("Clone TLA to new ticket for the new year - timeSpent " + timeSpent)
Number remaining = getRemaining(sourceIssue, timeSpent)
log.warn("Clone TLA to new ticket for the new year - remaining " + remaining)
Long estimate = 187.5 + remaining
log.warn("Clone TLA to new ticket for the new year - estimate " + estimate)
issue.estimate = estimate

private static BigDecimal getTimeSpent(Issue issue) {
BigDecimal timeSpent = issue.timeSpent
if (timeSpent != null) {
timeSpent = timeSpent / 3600
} else {
timeSpent = 0
}
timeSpent
}

private static Number getRemaining(Issue issue, BigDecimal usedTime) {
BigDecimal remaining = 0
if (issue.originalEstimate != null) {
remaining = (issue.originalEstimate) / 3600 - usedTime
}
remaining
}

The estimate value gets calculated correctly (issue.estimate = estimate), but somehow never stored in the new cloned ticket.
I'm running this as the first post function for a transition.
By the way: I'm running the latest version of ScriptRunner.

Does anybody have any hints on what I'm doing wrong here?

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
adammarkham
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 16, 2017

What happens if in the additional issue actions you do something like:

issue.setEstimate ( (long) 288000 )

Also what version of ScriptRunner are you using?

Jo-André Lia March 19, 2017

That didn't change anything. I'm still getting the value from the original issue that I'm cloning from.

I'm using the latest version - 4.3.18

adammarkham
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 20, 2017

Your likely not placing the post-function in the correct order. Please see here for where to place it: https://scriptrunner.adaptavist.com/4.3.18/jira/custom-workflow-functions.html#_post_functions

TAGS
AUG Leaders

Atlassian Community Events