Hello All,
I am able to update the sub-task issue custom field values(Text box) when parent issue is updated using below script in script listener:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
import org.apache.log4j.Logger
import org.apache.log4j.Level
def log = Logger.getLogger("com.hpe.cf")
log.setLevel(Level.INFO)
def partChange = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "Part Number"}
def partDescChange = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "Part Number Description"}
def partRgChange = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "Purge Region"}
if (partChange || partDescChange || partRgChange) {
//log.info( "Value changed from ${change.oldstring} to ${change.newstring}")
// your actions if the field has changed
def subtasks = event.issue.getSubTaskObjects()
String fName = ""
String fValue = ""
if(partDescChange) {
fValue = partDescChange.newstring
fName = "Text Field name"
} else if(partRgChange) {
fValue = partRgChange.newstring
fName = "Text Field Name"
} else {
fName = "Text Field name"
fValue = partChange.newstring
}
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName(fName)
if (subtasks){
subtasks.each {it ->
log.info(customField)
((MutableIssue) it).setCustomFieldValue(customField, fValue)
ComponentAccessor.getIssueManager().updateIssue(event.user, ((MutableIssue) it), EventDispatchOption.DO_NOT_DISPATCH, false)
log.info("******Updated*****")
}
}
}
But when i am trying to update the single select list and check Box custom fields values using above script is not working.
Can any one please help me with this issue. I am new to groovy script.
Thanks in Advance,
Mani