Forums

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

Data was not an array

Petr AST
Contributor
June 7, 2023

Dear community!

I have an approver field in a Service Management project managed by a team (decided to test the updates on a real project).
But the approval process is simplified in this type of project, it is impossible to remove a separate field of approvers from the business process, users can change at any time, and then send to them for approval, knowing the entire list of users in advance.

I added the following JSON to the field when creating the request:


{
"update": {
"customfield_10120" : [
{"add": {"accountId":"XXX"}},
{"add": {"accountId":"CCC"}}
],
"customfield_10121" : [
{"add": {"accountId":"XXX"}},
{"add": {"accountId":"CCC"}}
]
}
}

Accordingly, I have two fields - one is editable - 10121, the second is not.
How can I copy values from 10121 to 10120 field when changes (adding or removing users)?

I tried everything, but usually I got an error data was not an array (customfield_10120))

 

{
"update": {
"customfield_10120": [
{
"set": "customfield_10120"
}
]
}
}
{
"fields": {
"customfield_10120": "{{issue.fields.customfield_10121}}"
}
{
"update": {
"customfield_10120": [{
"add": {"id":"{{customfield_10121.accountId}}"}
}]
}

 Thanks in advance!

1 answer

1 accepted

3 votes
Answer accepted
Mikael Sandberg
Community Champion
June 7, 2023

In order to copy users from one user picker field field to another you have to do it one user at the time. So in your automation add an Advanced branching and set the smart value to the first field, and then edit the second field using this JSON:

{
"update": {
"customfield_10120": [{
"add": {
"id":"{{smartValue}}"
}
}]
}
}

Just replace the smartValue with the name that you gave it. 

Petr AST
Contributor
June 7, 2023

Hi @Mikael Sandberg 

Thanks for your answer!

What am I doing wrong? I see a error Specify a Valid value for Â«customfield_10120» (customfield_10120))Screenshot_18.png

Screenshot_19.png

Mikael Sandberg
Community Champion
June 8, 2023

Is customfield_10121 a single user picker field or multi-user? If it is a user picker field then you do not have to add .accountId when you set the smart value, that field will store the accountId already, but what you see is the display name.

Suggest an answer

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

Atlassian Community Events