Jira Automation Error "data was not an object" when trying to add values to a field via JSON

Bent Möller
Contributor
March 18, 2024

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.

2 answers

1 accepted

1 vote
Answer accepted
Ste Wright
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 18, 2024

Hi @Bent Möller 

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.

---

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

Bent Möller
Contributor
March 18, 2024

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

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

Ste Wright
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 18, 2024

Hi @Bent Möller 

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

Bent Möller
Contributor
March 18, 2024

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.

Ste Wright
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 18, 2024
Like Bent Möller likes this
Bent Möller
Contributor
March 18, 2024

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.

Like # people like this
0 votes
Kalyan Sattaluri
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 18, 2024

Hello @Bent Möller 

You mention this is a multi-select field if so, the syntax is like below as mentioned in docs.

{ "update": {

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

} }

Hope it helps. Thanks!

Bent Möller
Contributor
March 18, 2024

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.

Like Kalyan Sattaluri likes this
Kalyan Sattaluri
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 18, 2024

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

Like Bent Möller likes this

Suggest an answer

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

Atlassian Community Events