Setting Original Estimate with Java API

Hello there,

in a custom post function I’m trying to update the “Original Estimate” (copy from parent when triggered from a sub-task). With the IssueService it sounds pretty straight forward:

IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
issueInputParameters.setRetainExistingValuesWhenParameterNotProvided(true, true);
issueInputParameters.setSkipScreenCheck(true);
issueInputParameters.setOriginalEstimate((Long) value); // where value is the originalEstimate from the parent

IssueService.UpdateValidationResult updateValidationResult = issueService.validateUpdate(applicationUser, issue.getId(), issueInputParameters);
if (updateValidationResult.isValid()) {
            issueService.update(applicationUser, updateValidationResult);
} else {
           // handle error case
}

The first problem was, that internally (TimeTrackingSystemField.convertToIssueFormInModernMode()) the value is treated as the display value and gets converted to a long in Milliseconds again, what results in a totally wrong value. That seems like a bug to me. I found a workaround by translating the value in ms back in the display value and then setting it as a String on the issueInputParameters:

issueInputParameters.setOriginalEstimate(jiraDurationUtils.getShortFormattedDuration((Long) value, new Locale("en_UK")));

Now it seem to work, at least the history is telling me that. Although the displayed value of “Original Estimate” stays the same and doesn’t get updated.

I’m able to get it updated when I set Original Estimate additionally directly on the issue’s object:

issue.setOriginalEstimate((Long) value);

But 1. that’s not how IssueService is supposed to work and 2. the history data is wrong then, telling that the Remaining Estimate got updated too, although it displays with the old value.

What am I missing?
It’s like I opened Pandora’s box. :joy:

Best regards
Sascha