This is well beyond my limited knowledge of Json and how to manipulate things. I have an Epic that has been updated with a new Parent Link (initiative). This triggers my automation. For whatever reason, although I have the id of the Parent Link issue I do not get any of it's data and so I have had to retrieve the Parent Link issue via a restful call in a web hook action.
I want to set the components of the Epic to be the same as its parent Initiative. I am at a loss as to how to do this. I don't even know if it is possible for me to do this. I understand what the error message is telling me.... it wants an array of something. But should be an array of names, or ids? And is it possible to build an array of the right things from the info I have in the format it is in?
I have a write to log of:
Components are: {{webhookResponse.body.fields.components}}
and an advanced update issue action of:
{ "fields": { "components": "{{webhookResponse.body.fields.components}}" } }
Below is what this gives me
Hi @Guy Slade
When setting the components with JSON in a rule, please try the array syntax:
https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Components
As you are getting the data from the webhookResponse, first check if that is a list or an array by writing the value to the audit log. That will help to know how to convert it before use in the JSON.
If that does not help, please post an image of your complete rule and of the Edit Issue action details to provide more context.
Kind regards,
Bill
Hi Bill, I have written out what the response gives for body.fields.components above. I also have the content of the edit issue action up there. I am not sure what to make of the components I get back. Is it a list of lists?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, it is a list element, as text, and so the names of the components is this:
{{webhookResponse.body.fields.components.name}}
Using the components element directly in the edit likely does not work because the type is not recognized. You may make the dynamic JSON for the edit by iterating over the values:
{
"fields: {
"components" : [
{{#webhookResponse.body.fields.components.name}}
{ "name" : "{{.}}" }{{^last}}, {{/}}
{{/}}
]
}
}
That will add each component by name, with a comma separated the entries.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Bill, that worked. My homework is now to dissect your solution and understand what it is doing :).... I have lots to learn..... I have never seen '#' before, I also don't know how to read:
"{{.}}" }{{^last}}, {{/}}
{{/}}
Anyway, thank you
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.