Script a listener to update field from parent to same field across all subtasks

Hey All, 

 

So i have been trying to write a listener script with the help of a number of folks and am so close but haven't quite figured out the magic sauce. I have two fields (PO Number and Tracking Number) i need to populate down from the parent to all subtasks. As of now I have only been able to accomplish this with the first subtask but not the rest in the list. I was told i should consider an "each" loop but don't really know how to script that or if it is truly the correct approach. Attached is my script so far. I've called out in the script where i think i need some help. If anybody could lend a hand, i would certainly appreciate it. 

script.PNG

 

3 answers

3 accepted

these both worked out great!

Hi Scott,

You can do the following to loop through the sub task objects:

issue.subTaskObjects.each{
println("SubTask ID: ${it}")
}

You can do what you want with each subtask inside the curly braces. The variable "it" represents the sub task object (Issue) for each pass of the loop.

Steve

1 votes
Joshua Yamdogo Community Champion Dec 05, 2017

Hi Scott, 

Yes, iterating through the subtask issues with .each() would work fine here. It should be rather simple to do, like this:

issue.getSubTaskObjects().each { subtask ->
syncCustomFieldValue(issue, subtask, "yourNameOfField")

}

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,981 views 12 18
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot