[Automation] Advanced field editing (JSON) - add multiselect values

Krzesimir February 4, 2022

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:

  • triggered when parent link is added (Advanced Roadmap's parent link)
  • looks up the parent via the Lookup Issues function
  • edit issues --> here I want to add every looked up value to the child. Here's the code I use at the moment:
{
"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

1 answer

1 accepted

2 votes
Answer accepted
Krzesimir February 9, 2022

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:

Jira smart values - JSON functions documentation page

Sinisa Glusac August 10, 2022

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. 

Bill Sheboy
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.
August 10, 2022

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

Sinisa Glusac August 11, 2022

Ok, I will do it, thank you Bill. 

Like Bill Sheboy likes this

Suggest an answer

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

Atlassian Community Events