I have a use case where I am trying to get the first start and last end date to copy up from all subtasks in an issue to the parent. So far I am working in the Scriptrunner console to get it close before I turn it loose in a listener. I am able to capture all the information I need to set the value but it throws a "Cannot find matching method" error on the line that ostensibly should set the field value. What I have so far is based on a single subtask (for dev and debug) which DOES find the dates I want and the parent issue
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.Issue;
import java.sql.Timestamp;
import java.util.Date.*
def issueManager = ComponentAccessor.getIssueManager();
def startDateField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_11014");
def endDateField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_11015");
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
Issue sourceIssue = issueManager.getIssueObject("ITPROJECTS-295");
Issue parentIssue = sourceIssue.getParentObject();
def parentStartDate = parentIssue.getCustomFieldValue(startDateField)
def parentEndDate = parentIssue.getCustomFieldValue(endDateField)
Date startResult = null
Date endResult = null
def startResultTimeStamp
def endResultTimeStamp
Collection subTasks = parentIssue.getSubTaskObjects();
for(subtask in subTasks) {
def subTaskStartDate = subtask.getCustomFieldValue(startDateField) as Date
def subTaskEndDate = subtask.getCustomFieldValue(endDateField) as Date
if (startResult == null || (subTaskStartDate < startResult)){
startResult = subTaskStartDate
}
if (endResult == null || (subTaskEndDate > endResult)){
endResult = subTaskEndDate
}
}
if (parentStartDate != startResult && parentEndDate != endResult)
// return "${startResult} - ${endResult} for ${parentIssue} having Start ${parentStartDate} and End ${parentEndDate}"
parentIssue.setCustomFieldValue(parentStartDate, startResultTimeStamp)
This returns (with the return line uncommented) "2018-10-19 00:00:00.0 - 2018-12-05 00:00:00.0 for ITPROJECTS-518 having Start null and End null" which is what I expect. However the last line in the script is the one that is throwing the "Cannot find matching method" error. Anyone with ideas?