Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scriptrunner loop of Child Work Items

Andy Johnston
Contributor
November 25, 2025

Hi, I'm trying to do what appears to be a basic loop of Stories below the parent of an item. I'm sure I'm missing something simple, any help would be appreciated.

 

This is my Scriptrunner Listener.  Scoped to a specific type of work item.  I get the work item key, then get the parent, then get the stories from the parent.

I try to loop them using .each, and this logger does not output anything?

 

// Fetch the parent issue of the current Work Item

def eventIssue = Issues.getByKey(issue.key as String)

def parent = eventIssue.parentObject

// Fetch all children of the parent issue

def childWorkItems = parent.getStories()

logger.info("Total Child Work Items for ${parent.key}: ${childWorkItems.size()}: ${childWorkItems.toString()}");

//Trying to output something for debugging?

childWorkItems.each { story ->

     logger.info("Story Key: ${story.key}, Summary: ${story.summary}")

}

 

The item I'm editing is XYZ-649 in this log the edit fires the listener script.  The Parent is XYZ-416, which is also correct.

Then from this log line I can see that the stories (childWorkItems) size is 2, and the children are XYZ-649, and XYZ-670.  Both of these items ARE the child items of XYZ-416.  So things are looking good.

 

But then I try to get each story, and get the story key and summary... and I get nothing?  There is no error, so my syntax seems correct, but I'm not getting any info??  I'm missing something here... but I can't figure out what it is?! 

2025-11-25 23:58:16.293 INFO - GET /rest/api/2/issue/XYZ-649?expand=transitions%2Cnames%2Cschema asString Request Duration: 621ms
2025-11-25 23:58:17.632 INFO - GET /rest/api/2/issue/XYZ-416?expand=transitions%2Cnames%2Cschema asString Request Duration: 1335ms
2025-11-25 23:58:18.366 INFO - POST /rest/api/2/search/jql asString Request Duration: 716ms
2025-11-25 23:58:19.773 INFO - POST /rest/api/2/search/jql asString Request Duration: 1400ms
2025-11-25 23:58:20.206 INFO - POST /rest/api/2/search/approximate-count asString Request Duration: 431ms
2025-11-25 23:58:20.207 INFO - Total Child Work Items for XYZ-416: 2: [XYZ-670, XYZ-649]

0 answers

Suggest an answer

Log in or Sign up to answer