Jira Automation Error "data was not an object" when trying to add values to a field via JSON
Asked by Bent M?ller:

Hey there, I have a problem with editing a custom field via Automation and I just can't see the problem. I checked other Community posts, scrolled through <https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/> and used a JSON Validator.

I have a custom field "Permissions" that I want additional values to be added automatically when the created Issue is a specific Issue Type. If I got this correct, basic Automation only lets me SET or COPY values (and SET would overwrite the other values).

So instead I put an "Edit issue fields" into the automation and wrote the following into the Additional fields:

```
{
    "update": {
        "Permissions": [
            {
                "add": "Permission 1"
            },
            {
                "add": "Permission 2"
            },
            {
                "add": "Permission 3"
            }
        ]
    }
}?
```

However, when I run the automation I get an Error:
> Edit Issue
>
> Error editing issues
>
> (data was not an object (customfield_10283))

I also tried the customfield ID instead of the name, but nothing changes.


Answers:
author: Ste Wright
body: Hi [@Bent M?ller](/t5/user/viewprofilepage/user-id/5450479)

Just to confirm, are you trying to...

1. Set the field to existing values, or...
2. Add additional values to the actual field (i.e like you would in the Admin Settings)

...?

---

If it's **(1),**you shouldn't need to use JSON, you can just set the values from the Edit Issue Action's field options.

If it's **(2),** I've not seen this done using this method in Automation. You might be able to send a web request though - something like what is mentioned in [this answer](https://community.atlassian.com/t5/Jira-Software-questions/Add-values-to-select-list-via-automation/qaq-p/1995363#M557903).

---

**Edit:** Answer was found in here - <https://confluence.atlassian.com/automationkb/automation-for-jira-how-to-update-a-select-field-multiple-choices-from-the-content-of-other-fields-1236449082.html>

Ste

comments: author: Bent M?ller
body: The User creates an Issue.

When the Issue Type is Onboarding, the user will add some required permissions to the "Permissions" custom field, like "Permission 16, Permission 42, Permission 8".

Now for Onboardings, Permissions 1, 2 and 3 are always required. So when the issue is created, it should now automatically have "Permission 16, Permission 42, Permission 8, Permission 1, Permission 2, Permission 3" inside this Select List (multiple choices) Customfield.

According to <https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/> "update" is used in JSON to do this: "update can be useful for fields with multiple values, where you want to add and/or remove from the existing set."

And this page also has an example on how to add labels to an existing field this way:

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/312677i3B2F3A856B97118F/image-size/large?v=v2&px=999 "image.png")

So I am basically trying to do the same thing with a custom field.


author: Ste Wright
body: Hi [@Bent M?ller](/t5/user/viewprofilepage/user-id/5450479)

Why not just include Permissions 1, 2 and 3 in the SET option (i.e without the JSON).

I know SET can override the existing options but adding them in there should avoid that from happening when the extra Permissions are added.

Or is this just an example and there's many other permutations of this?

Ste


author: Bent M?ller
body: When a user creates an Onboarding it will be filled with quite a few permissions that always varies between departments. Its not a good idea to overwrite everything they put in there. Setting defaults in the customfield itself is also possible but then it will be set on every issue that uses the Permissions field, not just for Onboardings.

There is no convenient workaround for this except for "hard-coding" it into the workflow with extended Scriptrunner functionality, which I dont really want to do when the Atlassian Support Page tells me that its possible via JSON in Automation.


author: Ste Wright
body: Have you tried the suggestions on this article (I know it says Server) - see Scenario 2: <https://confluence.atlassian.com/automationkb/automation-for-jira-how-to-update-a-select-field-multiple-choices-from-the-content-of-other-fields-1236449082.html>

Ste


author: Bent M?ller
body: Yes, this is the solution!

Apparently Select List (multiple choices) works a bit differently.

So instead of

```
{
    "update": {
        "customfield_10283": [
            {
                "add": "Permission 1"
            },
            {
                "add": "Permission 2"
            },
            {
                "add": "Permission 3"
            }
        ]
    }
}
```

its

```
{
    "update": {
        "customfield_10283": [
            {
                "add": {"value": "Permission 1"}
            },
            {
                "add": {"value": "Permission 2"}
            },
            {
                "add": {"value": "Permission 3"}
            }
        ]
    }
}
```

Works like charme now.


author: Kalyan Sattaluri
body: Hello [@Bent M?ller](/t5/user/viewprofilepage/user-id/5450479)

You mention this is a [multi-select field](https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#:~:text=Multi%2Dselect%20custom,10112%20%7D%2C%20%7B%20%22id%22%3A%2010115%20%7D%20%5D)if so, the syntax is like below as mentioned in docs.

{ "update": {

"customfield_10283" : \[ { "value": "Permission 1" }, { "value": "Permission 2" } \]

} }

Hope it helps. Thanks!

comments: author: Bent M?ller
body: Yes I found the solution, the syntax was wrong, the "add" still has to be included though in this case so its:

"customfield_10283": \[{ "add": {"value": "Permission 1"}} etc.


author: Kalyan Sattaluri
body: Great. Wanted to add that for a field, you can look at below URL to get the meta data which tell you which operations are available for a field such as set, add, remove. Just FYI.

GET /rest/api/3/issue/{issueIdOrKey}/editmeta


Tags: automation

cloud

jira-cloud

jira-service-management

jira-service-management-cloud