Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to append in automation an array of values into multiple user field

Diogo Rodrigues March 22, 2025

Hello,

 

I've approvers field that I want to populate with data from multiple attributes in the linked asset.

I'm able to get the array from one attribute and set it into approvers.

However when I want to append another array I fail to succeed.

 

I'm able to append a single user using the update option using this documentation example:

 

{ "update":

{

"customfield_12345": [{

"add": { "value": "{{issue.customfield_12224}}" }

}]

}

}

 

However using the array it returns success but not appending values:

{ "update" :

{ "customfield_12345" : [ {

"add" : {{MyAssetField.AssetAtribute.flatten.asJsonObjectArray("id")}}

} ]

}

}

1 answer

0 votes
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.
March 22, 2025 edited

Hi @Diogo Rodrigues 

For a question like this, context is important for the community to help.  Please post the following:

  • an image of your complete automation rule in a single image for continuity
  • images of any relevant actions / conditions / branches
  • an image of the audit log details showing the rule execution

Until we see those...

 

In the examples you show, you appear to be adding two completely different values to customfield_12345: a single field value and an asset attribute.

First, have you tested the contents of your asset attribute contain what you expect?

Next, you are attempting to use the function asJsonObjectArray() incorrectly in two ways: with the wrong attribute of "id" versus "value", and trying to add an array within an array.

Finally, if your source information is indeed from an asset value, those are looked up just-in-time, and so there could be timing problems when the value is not provided fast enough to be used in the dynamic JSON expression.

 

Let's assume your asset data {{MyAssetField.AssetAttribute.flatten}} produces a comma-separated values list.  To solve the timing problem, that could be stored with Create Variable.  That variable could then be split() into a list, and iterated to create the dynamic JSON expression in the Edit Issue action (recently renamed to Edit Work Item action).

  • action: create variable
    • name: varAssetData
    • smart value: {{MyAssetField.AssetAttribute.flatten.join(",")}}
  • action: Edit Issue, with advanced edit and a JSON expression
{
"update": {
"customfield_12345": [
{{#varAssetData.split(",")}}
{ "add": { "value": "{{.}}" } } {{^last}},{{/}}
{{/}}
]
}
}

 

Kind regards,
Bill

Diogo Rodrigues March 23, 2025 edited

Hi @Bill Sheboy  thank you for replying.

 


I'm doing the same strategy for "fields" option and it works.

So proving more context.

  • Issue Linked with Asset.
  • Asset has 2 user attributes "System Owner" and "Process Owner" with 1 or more users.
  • I want to copy those users from those 2 attributes to my issue approvers that is a multiuser field.

 

I'm able to do the first copy as I'm using "fields" option under "additional fields" with following code:

Screenshot_1.jpg

 

I'm doing re-fetch to give some time to the first edition be processed.

 

However when I'm trying to update to append the 2nd attribute users and I fail to succeed.

I'm trying this code, that is the exact strategy as for Fields option:

Screenshot_2.jpg

 

The array (id) give function gives me the id format that we need as we can see in the log.

The log says the issue was successfully edited, but data is not appended.

 

Screenshot_3.jpg

 

 

BTW tested your code and returns error:

 

Error while parsing additional fields - Mismatched start/end tags: null != in template-9b3fxxxxxxxxxxxx
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.
March 23, 2025

Thank you for the additional information.

When using the "add" operation for the field, there can only be one value in the JSON, not a list of values.  That is why the iteration technique I noted is required to include an "add" expression for each one.

If instead you want to "set" the value to replace all of the values in the field, use the "fields" syntax as that is the same as using "update" with "set".

Diogo Rodrigues March 24, 2025

Understood. Actually I want to append information.

I used fields to set the info from 1st attribute. and want to append information from 2nd attribute.

I tried your suggestion but returned:

Error while parsing additional fields - Mismatched start/end tags: null != in template-9b3fxxxxxxxxxxxx
Diogo Rodrigues March 25, 2025

Hi @Bill Sheboy any suggestion on the correction of the code to overcome the error outcome?

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.
March 25, 2025

Sorry for the delay in responding; with the community site updates, some of the notifications were not working well.

Please post images of:

  • the complete current rule, in a single image for continuity
  • an image where the variable is created
  • an image of the edit issue action showing the advanced edit with the JSON expression

Thanks!

Diogo Rodrigues yesterday at 2:50 AM edited

Hello,

 

here it is. 

 

Screenshot_4.jpg

Screenshot_5 (2).jpg

Thanks

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.
yesterday at 8:43 AM edited

Oops...typo as the pound sign # is missing from my earlier post.  Please use this:

 

{
"update": {
"customfield_10003": [
{{#varSystemOwners.split(",")}}
{
"add": {
"value": "{{.}}"
}
} {{^last}},{{/}}
{{/}}
]
}
}

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, atlassian community, journeys for jira service management, journeys for jsm, eap jsm atlassian, early access program atlassian, early access program journeys atlassian, early access program journeys jira service management, join atlassian eap

Join the Early Access Program (EAP) - Journeys for Jira Service Management 🚪

Journeys is a brand new feature in Jira Service Management that helps you streamline various processes in your organization that may cross multiple departments, such as employee onboarding or off-boarding that require action from different teams. ✨

Join the EAP →
AUG Leaders

Atlassian Community Events