Cannot update estimate on an issue when using clone and link

Jo-André Lia April 7, 2017

Hi,

I've posted this one before, but it was in the old Atlassian Answers forum and it has been deleted so I have to post it again as I haven't found a solution to it yet.


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?

2 answers

1 accepted

0 votes
Answer accepted
Jo-André Lia April 26, 2017

I've found a solution/workaround. I use issue.originalEstimate instead. That works. Just have to add the estiamte in seconds instead of hours.

Still curious though why issue.estimate doesn't stick.

0 votes
JohnsonHoward
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.
April 12, 2017

Have you tried using the .setEstimate() method on the currentIssue.

And also passing the currentIssue variable into the methods instead of sourceIssue?

Jo-André Lia April 21, 2017

Yes I've tried it. Still no change.

Jo-André Lia April 26, 2017

I've gone back to basic here.

I've replaced everything that I had in the "Additional issue actions" with a single line:

issue.estimate = new Long(400)

 

The new cloned issue still gets the estimate from the original ticket.

I believe I'm looking at an error in the clone and link feature. Should I move this to the Scriptrunner support instead?

What do you think Johnson?

Suggest an answer

Log in or Sign up to answer