Hi there,
I have a rule using a value from the issues Epic link to set the a value of another field using automation.
Something like this, where "Bar" is an object type custom field with an array "list" in the epic
{
"fields": {
Foo: {{issue.epic.Bar.list.asJsonStringArray}}
}
}
I tried to use an "OR (|)" like this "{{issue.epic.Bar.list.asJsonStringArray|[]}}", but I think this fails as "epic" is not set.
Any idea how to fix this?
Hi @Paul Pasler
For a question like this, please post an image of your complete automation rule, images of any relevant actions / conditions / branches, an image of the audit log details showing the rule execution, and explain what is not working as expected. Those will provide context for the community to offer ideas. Thanks!
Until we see those...
Would you please clarify: are your two custom fields select list, multiple choice fields, or something else?
If they are, this is the syntax to set the field values with JSON: https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Multi-select-custom-field
If you are adding values, versus just setting them, the logic would be more complicated as the current values need to be included first.
And for this type of field, you likely want to use asJsonObjectArray instead:
Kind regards,
Bill
Hi Bill,
sorry if any context information were missing. I tried to distill the problem, so it's easier to see the core of my issue. As this is a prototype, there is not much more context yet, but this:
The custom field is a Forge custom field of type object with two properties ("texts", "colors") including arrays of strings. The value from the Epic link should be copied to a newly created target issue. If an issue has an linked Epic, it works as expected. But if there is no Epic, it fails and says "No valid JSON" (I assume there is undefined or null). I want to set a default value in case there is no linked Epic.
I hope this clears things up a bit.
Cheers,
paul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for clarifying the scenario.
First thing: I recommend confirming the smart value for your field in that expression. Smart values are name, spacing, and case-sensitive, and the often do not match the display name on the issue views. To confirm the smart values for your field, please check this how-to article: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/
Next, I recommend using a rule condition (on epic link / parent) or a conditional expression to solve this: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/
For example, with rule conditions like this:
Or, it could use a conditional expression and do this in-line, in a single edit. This shows doing this with a created variable to ensure the expression is parsed before it is used in the advanced edit.
"Maintenance status" : {
"text " :
{{#if(exists(issue.parent))}}add your field JSON here{{/}}
{{#if(not(exists(issue.parent)))}}add your default value JSON here{{/}}
,
"colors" :
{{#if(exists(issue.parent))}}add your field JSON here{{/}}
{{#if(not(exists(issue.parent)))}}add your default value JSON here{{/}}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy ,
thanks for the recommendations!
I went with the first suggestion, which is easier to maintain in my eyes.
The second approach did not work for me (although it should, according to the documentation...).
Cheers,
paul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am glad to learn that helped.
For that second approach, prebuilding the JSON in a created variable can be challenging to get correct. When doing this, I will write the variable to the audit log (and skip the edit) until I know my testing is complete. Then I'll add the edit action.
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.