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.
Hi @Bent Möller
Just to confirm, are you trying to...
...?
---
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
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:
So I am basically trying to do the same thing with a custom field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.