Cannot update estimate on an issue when using clone and link

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

Accepted Answer
0 votes

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
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

21,281 views 2 7
Join discussion

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