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:
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!
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}},{{/}}{{/}} ]
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.