I have a Issue, which contains a field "Total Cost".
That issue has a series of SubTasks, each with a "Cost" field.
I want to collect the "Costs" of all these subtasks, total that value, and update that value to the "Total Cost" of their parent issue's custom field "Total Cost".
Ideally, I'd like to do this whenever one of these Issue Types is updated.
I've managed to gather a list of the SubTasks' ids, but when I apply the same code to open up those SubTasks, it fails. Here's my code:
***
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
IssueManager im = ComponentAccessor.getIssueManager()
MutableIssue issue = im.getIssueObject("PUB-239")
def IssueType = issue.issueType.name;
def OutPut = "";
MutableIssue subTaskDetails;
if(IssueType == 'Format Title'){
// Get the issue's Total Cost Field
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def cField = customFieldManager.getCustomFieldObjectsByName("Total Cost");
def cFieldValue = issue.getCustomFieldValue(cField[0]);
if(cFieldValue != "250"){
def getArrayLength = issue.getSubTaskObjects().size();
OutPut = "Array Length Check: "+getArrayLength;
if(getArrayLength > 0){
for(int i = 0; i<getArrayLength; i++) {
def subTaskId = im.getIssueObject(issue.getSubTaskObjects()[i].toString());
subTaskDetails = im.getIssueObject(subTaskId);
}
}
}
}
return OutPut;
***
The last line: "subTaskDetails = im.getIssueObject(subTaskId);" Is triggering the following error:
"[Static type checking] - Cannot find matching method com.atlassian.jira.issue.IssueManager#getIssueObject(com.atlassian.jira.issue.MutableIssue). Please check if the declared type is correct and if the method exists."
Apparently, Mutable Issues created by the IssueManager don't have access to the "getIssueObject()" method...
But I already used it successfully, earlier in the code!
Can anyone help me?