I'm having some difficulty getting the duedate set on the subtasks using a customer listener on scriptrunner. I was simply using the setduedate function but couldn't get it to write. Googling led me down a lot of odd paths from trying to use store (per Jira instructions that seem outdated) to adding the four lines embedded in the subtasks.each loop. Would love a hand or some guidance.
Note: Currently get an error on the updateValue function call.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.event.type.EventDispatchOption
log.setLevel(org.apache.log4j.Level.INFO)
log.info("start");
IssueManager issueManager = ComponentAccessor.getIssueManager();
// Check if Due Date changed
if (event.getChangeLog().getRelated("ChildChangeItem").find {it.field == "duedate"})
{
def Due = event.issue.dueDate
log.info ("Due Date changed")
def subtasks = event.issue.getSubTaskObjects()
log.info ("${Arrays.toString(subtasks)}")
//log.info ("${subtasks.length} subtasks exist")
subtasks.each {
Issue issue = issueManager.getIssueObject(it.getKey())
MutableIssue mutableIssue = (MutableIssue)issue;
mutableIssue.setDueDate(Due);
issueManager.updateValue("Time", mutableIssue, EventDispatchOption.DO_NOT_DISPATCH, false);
log.info ("Date Date for ${mutableIssue} changed to ${Due}. ")
}
}
else {
log.info("Due Date not changed. ${event.getChangeLog().getRelated("ChildChangeItem")}");
}