Hi there,
I'm almost there with my automation that copies values from select List (multiple choice) custom field from parent to children, but I'm struggling with JSON syntax.
My rule works as follows:
{
"update": {
"customfield_10820": [{"add":""}{{#lookupIssues.customfield_10820}},{"add": "{{.}}"}{{/}}]
}
}
But I keep getting this error: data was not an object (customfield_10820))
I figure I'm missing "value" somewhere in the syntax. I played around a lot using great tips from @Erik Buchholz from the following threads, but still can't figure this out:
How to copy multi-value field in using Advance Options in Automation Rule?
If else in Automation for Jira advanced field editing JSON
Any JSON expert out there who'd be able to help out? :)
Cheers,
Krzesimir
Okay, after hours of trial and error, I managed to get it to work. Having the multi-select options copied as JSON object array did the trick:
{
"fields": {
"customfield_10820": {{#lookupIssues}} {{customfield_10820.asJsonObjectArray("value") }}{{/}}
}
}
Here's the version that adds values instead of overwriting them:
{
"update": {
"customfield_10820" : [ {{#lookupIssues}}{{#customfield_10820}} {"add": {{value.asJsonObject("value")}} } {{^last}},{{/}}{{/}}{{/}} ]
}
}
Although it throws an error if (a) there are no values in parent or (b) the existing values are the same as in the parent, so you'll need to add two following conditions for it to work like a charm:
{{issue.customfield_10820.value}}
does not equal
Empty
and
{{lookupIssues.customfield_10820.value}}
does not equal
[{{issue.customfield_10820.value}}]
Mind the square brackets in last line of the second condition!
This documentation page guided me in the right direction:
Hi @Krzesimir ,
I've tried to do the same, copied your JSON formula (changed custom field ID ofc) but for me, it doesn't work. It won't even add value to the field. Please advise. Thank you in advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Sinisa Glusac -- Welcome to the Atlassian Community!
First thing, I recommend posting a new question and linking to this earlier one. Otherwise only the people following this older thread will see it and make suggestions. Thanks!
Next, context is important for using the advanced edit for JSON. For example, the specifics of your field and its type can impact what is needed. Please post images of your complete rule, the details of your field and the JSON used, and of the audit log details showing what happens that you do not expect.
Kind regards,
Bill
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.
Hello.
I have a similar case, I think. I need to set a value in a Multiselect field, but I am not sure about the structure that works for this. Could you help me a hand here?
I tried with this, but it does not work.
{
"update": {
"customfield_10880":
[{"add":"Derco Center"}]
}
}
I tried this, even is succesfull, the field is not updated.
{
"Fields": {
"customfield_10880":
[{"value":"Derco Center"}]
}
}
I will really apreciate your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I could do it :)
{
"update": {
"customfield_10880":[{
"add":{"value":"Derco Center"}
}]
}
}
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.