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?
Community moderators have prevented the ability to post new answers.
What happens if in the additional issue actions you do something like:
issue.setEstimate ( (long) 288000 )
Also what version of ScriptRunner are you using?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.