I want to update the Assignee field from Parent to Subtask. When i update parent assignee field it should update all subtask assignee field.
import com.atlassian.jira.issue.Issue
//import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
Issue issue = event.issue
def cwdUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def currentAssigneeId = issue.getAssigneeId()
log.warn("currentAssigneeId")
def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == currentAssigneeId};
log.warn("childChangeItem")
//def currentAssigneeIdValue = change.currentAssigneeIdValue as String
def currentAssigneeIdValue = issue.currentAssigneeIdValue() as String
log.debug "new value is : ${currentAssigneeIdValue} "
if (change) {
//def currentAssigneeIdValue = change.currentAssigneeIdValue as String
// log.debug "new value is : ${currentAssigneeIdValue} "
issue.getSubTaskObjects()?.
findAll { it.issueType.name in ["Sub-task"]
//get only issues that their issue type is Sub-task
def subtask = ComponentAccessor.getIssueManager().getIssueByCurrentKey(it.key)
subtask.setAssigneeId(currentAssigneeIdValue)
log.warn("Assignee----")
ComponentAccessor.getIssueManager().updateIssue(cwdUser, subtask, EventDispatchOption.DO_NOT_DISPATCH, false)
}
}
Please help on this script.
Thanks,
Sai