Data was not an array for a Insight objects field
Asked by Fabio Manzoni:

Hi Guys,

I'm creating an automation that when a value is changed it is updated in another issue that is linked.

However, the field is an Insight object and it does not appear in the list of available fields, I am using the advanced session and I receive an error message Data was not an array

This is my code

{  
"fields": {  
"customfield_XXXX":"{{triggerIssue.fields.customfield_XXXXX}}"  
}  
}

Can someone help me?

BR,

Fabio


Answers:
author: Darryl Lee
body: WELL. This was a journey.

As you discovered, [@Fabio Manzoni](/t5/user/viewprofilepage/user-id/1171929) for some reason Asset object custom fields apparently no longer show up in the **Edit Fields** action. I don't know if this is a change from [Insight being an add-on to now being integrated with JSM Premium](https://confluence.atlassian.com/insightapps/insight-for-jira-cloud-1086395184.html) but for whatever reason, these instructions DO NOT WORK:

* [Copying values between Asset object field and multi-select custom field using Automation](https://confluence.atlassian.com/jirakb/copying-values-between-asset-object-field-and-multi-select-custom-field-using-automation-1141504943.html)

Instead, you were right - this required Additional Fields (formatted in JSON), **and** I had to do a bunch of digging.

First off, you're going to need to do a **Lookup objects** to *find* the objects with your current issue:

![Screen Shot 2022-12-19 at 2.41.46 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/231258i38EFEC13C3CFCC30/image-size/large?v=v2&px=999 "Screen Shot 2022-12-19 at 2.41.46 PM.png")

```
object HAVING connectedTickets(key={{issue.key}})
```

That returns all objects connected to your ticket as a list. So then, using [list operators](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/), you can construct an array object. But hold on, you first need your [Assets Workspace Id](https://developer.atlassian.com/cloud/assets/intro/introduction-and-basics/). I found this by going to:

```
https://MYSITE.atlassian.net/rest/servicedeskapi/assets/workspace
```

You need that Workspace ID because you'll need it for the JSON, as per this excellent reference: [JSON input for fields](https://innovalog.atlassian.net/wiki/spaces/JMWEC/pages/139009972/JSON+input+for+fields?showComments=true&showCommentArea=true) (I took a wild guess that the long string was a Workspace Id)

So then, **For Linked issues** , I am Editing each one and this is what I'm putting into **Additional fields:**

```
{
? ?"fields": {
? ? ? ? "My Asset": [
? ? ? ? ?{{#lookupObjects}}{"id": "MYWORKSPACEID:{{id}}"}{{^last}},{{/}}{{/}}
? ? ? ]
? ?}
}
```

(Where my Asset object field is named "My Asset")

(OOOOF, after I dug all this info up myself, I found this KB article that has a little information about the change: [Workarounds to automatically link the Asset object to Jira issues)](https://confluence.atlassian.com/jirakb/workarounds-to-automatically-link-the-asset-object-to-jira-issues-1079345661.html)

comments: author: Darryl Lee
body: What's really odd is that last link is specifically talking about the "new" Assets in JSM, and makes it seem like the easier solution (just doing an Edit issue in Automation) ought to work:

![Screen Shot 2022-12-19 at 3.03.00 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/231263i775C4619AB0B7F88/image-size/large?v=v2&px=999 "Screen Shot 2022-12-19 at 3.03.00 PM.png")

But in my testing, I could **not** see my **Asset object**custom field available for editing in Automation.

[@Grady Gausman](/t5/user/viewprofilepage/user-id/4547748) or [@Charlotte Nicolaou](/t5/user/viewprofilepage/user-id/4068798) - since you've posted about Assets and Insights before, I'm wondering if you might know anything about this.


author: Darryl Lee
body: Ah, figured it out, thanks to opening a Support ticket and getting help from [@Lucas Silva](/t5/user/viewprofilepage/user-id/4598719) !

Even though my rule had a manual trigger, it was only scoped for a Single Project, and I guess Automation thought I might be trying to copy it to another project, per this KB article:

* [How to copy Assets object field values from Jira Software projects to another Jira project using Automation](https://confluence.atlassian.com/jirakb/how-to-copy-assets-object-field-values-from-jira-software-projects-to-another-jira-project-using-automation-1130377240.html)

So to get the Asset field to show up for regular editing, I had to make my rule Global.

I was then able to create this much simpler rule:

![Screen Shot 2022-12-20 at 2.00.22 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/231447i986F0591F0327734/image-size/large?v=v2&px=999 "Screen Shot 2022-12-20 at 2.00.22 PM.png")

Your trigger, I assume, would be if the "My Asset" field is changed.


author: Darryl Lee
body: Actually now that I've played with it, you probably want to just:
> Copy **YOUR FIELD** from **Current Issue**

Like so:

**![Screen Shot 2022-12-20 at 2.03.04 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/231448i973DCBCC1610B75E/image-size/large?v=v2&px=999 "Screen Shot 2022-12-20 at 2.03.04 PM.png")**


author: Darryl Lee
body: One caveat is that both using SET and COPY appear to **add** assets to the linked issue, but not REMOVE any.


author: Fabio Manzoni
body: [@Darryl Lee](/t5/user/viewprofilepage/user-id/1365322)

I did your steps a few times and it showed a success message, but the issue was not edited.

I tried another approach and worked.

It so happens that my insight field (assets) is used in software and service management projects. And the copying of the values ??occurs exactly between these types of project and that's reason that the field doens't appear.

To solve it, I set the automation to Global, so my field started to appear in the edit issue.

Once the configuration was done, I returned my automation to Multi-project and selected my projects. With that it worked normally.


author: Darryl Lee
body: Hi [@Fabio Manzoni](/t5/user/viewprofilepage/user-id/1171929) --

According to this KB article, there is a separate Automation action for Editing Objects - you don't edit it as a field:

[Update object attribute values using automation with JSM Assets](https://confluence.atlassian.com/jirakb/update-insight-object-attribute-values-using-automation-1072218921.html)

There's also links to several examples.

Hope this helps!

comments: author: Fabio Manzoni
body: Hi [@Darryl Lee](/t5/user/viewprofilepage/user-id/1365322)

Thank you for your answer, but in my case I need to update a issue value. The documentation cannot help me.

Example that I need.

issue 1 the value is Database

issue 2 the valueis empty

Both issues are linked then I need to copie the value Database to issue 2.

BR,

Fabio


Tags: cloud

jira-service-desk-cloud

jira-service-management-cloud