I am trying to write a scripted listener that will copy down a Custom Field's value (Select List) from parent to child on creation.
I am trying to avoid using a post function, as I want this rule to fire across an entire project whenever a sub-task is created.
I currently have a listener that is working whenever the Parent is UPDATED...
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "Source of Request - JudahTest"}
if (change) {
log.debug "Value changed from ${change.oldstring} to ${change.newstring}"
def subtasks = event.issue.getSubTaskObjects()
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Source of Request - JudahTest")
if (subtasks){
subtasks.each {it ->
def options = ComponentAccessor.getOptionsManager().getOptions(customField.getRelevantConfig(it))
((MutableIssue) it).setCustomFieldValue(customField, options.find {it.value == change.newstring})
ComponentAccessor.getIssueManager().updateIssue(event.user, ((MutableIssue) it), EventDispatchOption.DO_NOT_DISPATCH, false)
}
}
}
Unfortunately, simply changing the listening event did not work. I need this to update on Issue Created! Any one out there want to help tackle this??