Match parent components to components from all child issues

Simon Jones May 31, 2024

I'm trying to update the list of components on an Epic to match the components on all of it's child issues, whenever any child has it's components updated.

For this example I have a single Epic with two child User Stories. They each have the following components:

  • User Story 1: Test 1
  • User Story 2: Test 2, Test 3
  • Epic: (should update to: Test 1, Test 2, Test 3)

I can't remove specific components from the parent because they should remain if they exist on other child issues, so I've written one automation to delete all components from the parent whenever a child's components are edited. I'm now trying to write a second automation which will be triggered by that parent field edit.

 


The second automation should collect the components from each of the child issues and then update the parent components field.

The automation uses a branch rule "for: Children"

Then: Create variable, named: "childComponents" with smart value:

{{issue.Components.asJsonObjectArray("name")}}

Then back on the main branch: Edit issue fields, selected fields: Components, Additional fields:

{
"fields": {
"components" : {{childComponents}}
}
}

However, the audit log returns the error:

Error while parsing additional fields. Not valid JSON.

 


I've enabled a manual trigger and value logging for debugging, which returns:

[{ "name": "Test 1" }], [{ "name": "Test 2" },{ "name": "Test 3" }]

 

How can I concatenate the array values so that I can use the final array to update the parent components? Something like:

[{ "name": "Test 1" },{ "name": "Test 2" },{ "name": "Test 3" }]

 

Alternatively... is there a better way of doing all this?

 

Many thanks!

 

Test.png

1 answer

1 accepted

0 votes
Answer accepted
Stevan Mandić
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 2, 2024
Simon Jones June 3, 2024

Thanks, @Stevan Mandić (and @Kalyan Sattaluri)!
That tidies the component formatting and also packages it into a single automation rule, in my case triggered by an edit to any child issue component field. 

 

For any future reference, here's a summary tweaked to my particular need:

 

1) Lookup issues - JQL:

issuekey in portfolioChildIssuesOf("{{issue.Parent}}") and issuetype in (Story, Task, Bug)

 

2) Create variable - "childComponents":

{{lookupIssues.Components.name}}

 

3) Branch For: Parent

 

4) Edit issue fields - More options:

{
"fields": {
"components": [ {{#childComponents.remove("[").remove("]").split(",").trim}}{ "name": "{{.}}" }{{^last}},{{/}}{{/}} ]
}
}

 

 

1.png

Like # people like this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events