Hi,
I want to update a custom field value in a sub-task if in the parent task the custom field value was updated, with Script Listeners.
The sub-task custom field and task custom field are the same field.
Thank you for your help.
Hello @Rafael Moreira,
You can create a script listener with IssueUpdated event and copy the code below. Hope this helps.
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.event.type.EventDispatchOptionimport com.atlassian.jira.issue.Issueimport com.atlassian.jira.issue.MutableIssueimport com.atlassian.jira.issue.fields.CustomFieldimport com.atlassian.jira.user.ApplicationUserString cfName = "CustomField name here" // Change thisIssue currentIssue = event.issueApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == cfName}if(change) { CustomField cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectsByName(cfName) Collection<Issue> subtasks = currentIssue.getSubTaskObjects();for(MutableIssue subtask : subtasks){ subtask.setCustomFieldValue(cf, cf.getValue(currentIssue)) ComponentAccessor.getIssueManager().updateIssue(user, subtask, EventDispatchOption.DO_NOT_DISPATCH, false) }}
Do not forget to change cfName value with the customfield name you want.
Kind Regards.
Orkun Gedik
Thank you for your answer, but I don't understand why I have this two errors that you can see in the print screen.
Can you help me please ?
Hi @Rafael Moreira,
Sorry for typo. Can you try to change
getCustomFieldObjectsByName()
with
getCustomFieldObjectByName()
Hi @Orkun Gedik
I still have one error
It looks like you're new here. Sign in or register to get started.