How to set remaining estimate

Hi all.

In our jira server instance, we need to set remaining estimate to 0 when an issue is resolved. I’ve been trying to reset it through two ways:

Issue issue = issueEvent.getIssue();
IssueManager issueManager = ComponentAccessor.getIssueManager();
MutableIssue mIssue = issueManager.getIssueObject(issue.getKey());
mIssue.setEstimate(0L);
issueManager.updateIssue(user, mIssue, EventDispatchOption.ISSUE_ASSIGNED, false);

and

Issue issue = issueEvent.getIssue();
IssueService issueService = ComponentAccessor.getIssueService();
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
issueInputParameters.setRemainingEstimate(0L);

IssueService.UpdateValidationResult validateUpdateResult = issueService.validateUpdate(user, issue.getId(), issueInputParameters);

if(validateUpdateResult.isValid()) {
       IssueService.IssueResult updateResult = issueService.update(user, validateUpdateResult);
       if (!updateResult.isValid()) {
           	log.debug("the issue update failed");
      }
 }

Both ways seem to work when you check the issue Activity>History tab, but they don’t update the TimeTracking section. In fact after checking the database, I can confirm that the update didn’t change the remaining estimate.

Can someone help??

Thank you!

Hi pallardo,

I’m having a similar issue with updating the original estimate. When using the IssueService, the History entry is correct, but the view doesn’t update. Try to set the remaining estimate additionally on the issue object:

issue.setEstimate(0L);

That could lead to wrong history data, saying that the original estimate got changed too.
My workaround:

final Long oldOriginalEstimate = issue.getOriginalEstimate();
issue.setEstimate(0L);
issue.setOriginalEstimate(oldOriginalEstimate);

That keeps the old value of original estimate and history should look fine.

Disclaimer: this is just a workaround. I’m still looking for a real solution.

Best regards
Sascha