Updating Original Estimate after Work has been logged on issue.

Cristina Gatt September 3, 2019

Hi, 

We are having a problem in JIRA Version: 7.9.2, Script Runner Version: 5.5.3 when we try to edit the Original Estimate after work has been logged on issue. 

When there is no log work on the issue, the code below works fine, but this is not working when there is time logged on the issue.

issue.setOriginalEstimate(updatedEstimate as Long)
ComponentAccessor.getIssueManager().updateIssue(users, issue, EventDispatchOption.DO_NOT_DISPATCH,false);

 The code that updates even if work is logged on the issue, is when we use 'issue.store()' instead of 'ComponentAccessor.getIssueManager.updatedIssue(args) but this is deprecated. 

The code with the deprecated function is this:


issue.setOriginalEstimate(updatedEstimate as Long)
issue.store()

 

I also tried using IssueInputParameters, but this does not work either. I checked the Timetracking settings and  Legacy Mode is also disabled but still not working :(  

Any hints please on how this can be solved without using the deprecated function?

1 answer

1 accepted

1 vote
Answer accepted
PD Sheehan
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.
September 3, 2019
Cristina Gatt September 4, 2019

IssueService didn't work for me. I'm trying to populate the Original Estimate field via a script listener initiated on Issue updated and work logged on issue. 

PD Sheehan
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.
September 4, 2019

When I try to just update the originalEstimate in the console using issueManager.updateIssue, it only updates the remaining estimate. There seems to be some built-in logic to keep the originalEstimates from being changed. Which is the whole point of having original and remaining estimate.

But when I use the issueService, I was able to change the originalEstimate only.

Cristina Gatt September 5, 2019

I tried again, but still didn't manage. I tried both in a post function and also in a listener.  Is there something wrong with my code? 


IssueService issueService = ComponentAccessor.getIssueService()
IssueInputParameters inputParameters = issueService.newIssueInputParameters()

inputParameters.setOriginalEstimate((long)temp)

IssueService.UpdateValidationResult validationResult = issueService.validateUpdate(users,issue.id,inputParameters)
if(validationResult.isValid()){
log.error("UPDATE VALID")
issueService.update(users, validationResult)
}else{
log.error(validationResult.errorCollection)
}

 I tried updating other fields such as Assignee and Description using the appropriate functions and this worked fine but nothing for Original Estimate. 

I also tried removing the Original Estimate value before setting it again via the script but didn't manage to populate it with the new value. 

I also tried passing fixed values (both string and long) maybe there is something wrong with the calculation but still didn't manage to update the Original Estimate

PD Sheehan
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.
September 5, 2019

Ah, I found something that might explain the difference

https://confluence.atlassian.com/adminjiraserver/configuring-time-tracking-938847808.html

I would wager that you have "Legacy Mode" enabled.

If you disable it (the default behavior), then you will be able to update the original separately from the remaining estimate.

Cristina Gatt September 5, 2019

Legacy mode is disabled in our instance. I also tried to enable and disable again just in case it wasn't disabled properly.

I also tried running it from script console, but still no success. 

PD Sheehan
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.
September 5, 2019

Then I'm not sure what else to suggest. The following works just fine for me in the scriptrunner console:

import com.atlassian.jira.component.ComponentAccessor

def issueService = ComponentAccessor.issueService
def issueManager = ComponentAccessor.issueManager
def inputParameters = issueService.newIssueInputParameters()
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser

def issue = issueManager.getIssueObject('JSP-1922')
inputParameters.originalEstimate =(Long)(2)

def validationResult = issueService.validateUpdate(user,issue.id,inputParameters)
issueService.update(user, validationResult)
Like Manuel Santiago Risquez likes this
Cristina Gatt September 5, 2019

Thank you for helping out :) This worked for me too. The problem was not in the code but  that I didn't have the field Time tracking in the Edit Screen of the issue so it couldn't be updated. Thank you very much for your help. It was greatly appreciated. 

Like Ariel Zambrana likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events