Jira 7.7.2 and Script runner plugin 5.5.0
Here is my requirement. I have DEV Estimate and BA Estimate custom fields. We needs to take total of these 2 fields and then update in original estimate.
I have written code in script listener and its updating original estimate and remaining estimate if DEV estimate and BA estimate change . So far good
But Its not working when user log the hour (log work) and then change DEV or BA estimation. It should add both DEV and BA estimation values and then update in original estimation. whereas remaining hours getting update fine.
Here is my code. Please let me know whats wrong in my code.
package com.custom
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.event.type.EventDispatchOption;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.IssueInputParameters
import org.apache.log4j.Category;
log.setLevel(org.apache.log4j.Level.DEBUG)
MutableIssue issue = event.issue as MutableIssue
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def orgEstDEV = customFieldManager.getCustomFieldObjectByName("Original Estimate DEV")
def orgEstDEV_Val = issue.getCustomFieldValue(orgEstDEV)
def orgEstBA = customFieldManager.getCustomFieldObjectByName("Original Estimate BA")
def orgEstBA_Val = issue.getCustomFieldValue(orgEstBA)
//log.debug "BA val = ${orgEstBA_Val}"
//long totalDEVBAEst = (((orgEstDEV_Val!=null) ? orgEstDEV_Val : 0) + ((orgEstBA_Val!=null) ? orgEstBA_Val : 0))
long totalDEVBAEst = orgEstDEV_Val + orgEstBA_Val
long origEstvalue = totalDEVBAEst * 3600
log.debug "Original est = ${origEstvalue}"
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
//Remaining hours
def TTSpent = issue.getTimeSpent();
if(TTSpent < 0 || TTSpent == "null" || TTSpent == ""){ //Keep the Remaining Estimate from going into a negative number
TTSpent = 0;
}
long REst = origEstvalue - TTSpent;
issue.setEstimate(REst);
issue.setOriginalEstimate(origEstvalue)
def IssueManager issueManager = ComponentAccessor.issueManager
issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH ,false)
Hi,
We are having the same problem. JIRA Version: 7.9.2, Script Runner Version: 5.5.3
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.