Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Script Runner- Update subtask custom field based on parent


Scenario: My team sends a Tempo extract of hours logged on tickets to finance team once a month.  Before we send the report- we need to ensure all the ticket fields are flagged properly.  A major issue we encounter is when subtasks custom fields become out of sync from their parent tasks.  I have the subtasks inheriting parent custom fields on create- however when someone updates a field on the parent and forgets to update the children they can become out of sync.

Question: Can I get help writing a script I can run on the Script Runner console once a month before I pull the report to ensure all the parent and child tickets in the project are in sync?  Is this feasible or is there a better solution?  Thanks so much

1 answer

1 accepted

A better solution would be writing a script listener that fires on issueUpdated event and fills in the child custom fields accordingly.


I have the same problem and I have  try a code but nothing happend

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 == "Labels"}
if (change) {
    log.debug "Value changed from ${change.oldstring} to ${change.newstring}"
    // your actions if the field has changed
    def subtasks = event.issue.getSubTaskObjects()
    def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Labels")
    if (subtasks){
        subtasks.each {it ->
            ((MutableIssue) it).setCustomFieldValue(customField, change.newstring)
            ComponentAccessor.getIssueManager().updateIssue(event.user, ((MutableIssue) it), EventDispatchOption.DO_NOT_DISPATCH, false)

 Can you help me please ?

Thank you

@Rafael Moreira Hi
Use it:

def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "labels"}

Hi Folks,

This mine script (works for me)

Perhaps it helps to some1 else.

import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor

def event = event as IssueEvent
def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "Contributors"}

if (event) {
def issue = event.issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def changeHolder = new DefaultIssueChangeHolder()

def targetField = customFieldManager.getCustomFieldObjects(event.issue).find { == "Contributors"}
def sourceField = customFieldManager.getCustomFieldObjects(event.issue).find { == "Contributors"}

targetField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(targetField), issue.getCustomFieldValue(sourceField)), changeHolder)

//update the UserPicker2 in subtasks as well - with the value of UserPicker from parent issue
issue.subTaskObjects?.each { subtask ->
targetField.updateValue(null, subtask, new ModifiedValue(subtask.getCustomFieldValue(targetField), issue.getCustomFieldValue(sourceField)), changeHolder)

Hi Guys,

I have a requirement where i need your help to write a script ,

When a custom field is getting updated in subtask , then changes should automatically reflect in parent task.

Please help

Thanks in advance.

Like Tejas Naik likes this

I have automated this now

Like Joe Yesh likes this

Hi Tanu,

Can you share your code snippet if your automation is working fine?

I too same requirement where I need few fields in the parent should sync to sub-tasks whenever there is a change in parent ticket.



@Joe Yesh I have ended up using a postfunction available from JWME add-on, on subtask workflow. 

Copy field value to parent issue (JMWE add-on)Copy the value(s) of a field to a field of the parent issue

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you