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?
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.