Forums

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

Removing value from a group picker field

Ivan D August 5, 2021

Hello,

I need to remove a value from a group picker (multiple values) field "customfield_11111". Using the following format for Additional fields in Edit action:

{
"update": {
"customfield_11111": [
{
"remove": {
"value":"group_name"
}
}
]
}
}

I get this error: 

Error editing issues AC-4520 (Operation value must be an array of group objects (customfield_11111)).

Appreciate any idea how to make it working.

2 answers

1 accepted

7 votes
Answer accepted
Darryl Lee
Community Champion
August 5, 2021

Whoops, ok, here's the fix:

{
"update": {
"customfield_11111": [{ "remove": { "name":"group_name" } }]
}
}

The trick was changing from value to name. The clue was here:

REMOVE: Removes an element from a field that is an array. The incoming value must be the same shape as the items of the array in a GET (although you can remove parts of the object that are not needed to uniquely identify the object).

What I did was look at the JSON of an issue: 

https://MYSITE.atlassian.net/rest/api/latest/issue/HELP-20

And therein I saw:

"customfield_10097": [
  {
    "name": "jira-software-users",
"self": "https://MYSITE.atlassian.net/rest/api/2/group?groupname=jira-software-users"
},
{
"name": "shift2",
"self": "https://MYSITE.atlassian.net/rest/api/2/group?groupname=shift2"
},
{
"name": "shift3",
"self": "https://MYSITE.atlassian.net/rest/api/2/group?groupname=shift3"
}
]

So then, when you remove an object, it has to match. So name, not value. But as the docs state, you don't need self, since name is unique enough.

Ivan D August 6, 2021

Hi @Darryl Lee

Thanks a ton, it works!

Just wondering why Atlassian doesn't put a couple of examples in the automation guide for such ambiguous cases.

Like Bill Sheboy likes this
Fazila Ashraf
Community Champion
July 25, 2023

@Darryl Lee  , you saved a lot of my time today! Thank you!

Like Darryl Lee likes this
0 votes
Darryl Lee
Community Champion
August 5, 2021

I've yet to test this, but I think this is right:

{
"update": {
"customfield_11111": [{ "remove": { "value":"group_name" } }]
}
}

I used this for reference: https://developer.atlassian.com/server/jira/platform/updating-an-issue-via-the-jira-rest-apis-6848604/#operation--verb--based-update--explicit-verb-via--update-- 

Bill Sheboy
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.
August 5, 2021

Hi there!

@Darryl Lee   If I remove the spacing from your suggestion it is identical to what @Ivan D posted.  Are you noting this is a spacing issue?  Thanks!

@Ivan D You are showing a literal value for "group_name".  Is it indeed a literal value or is it a smart value, such as "{{issue.someField}}"?

Best regards,
Bill

Darryl Lee
Community Champion
August 5, 2021

Ah crap, you're completely right @Bill Sheboy! I at first added some extra brackets, then double-checked the docs and came up with my code which yup, is exactly the same. :-/

The other thing I was wondering is if group objects need to be referenced by ID (a la users) instead of names.

Ivan D August 6, 2021

Hi @Bill Sheboy 

It's literal name.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events