Cannot update estimate on an issue when using clone and link


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

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

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
Accepted answer

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.

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

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

Yes I've tried it. Still no change.

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
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,173 views 5 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you