You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Hi there,
Is there a way where we can remove users from a custom field which is of type - Multi User field with the help of automation or script?
I have been trying with Automation but no luck.
Below is my JSON which I am using in Automation-
{
"update": {
"customfield_14296": [{
"remove": {"accountId":"12345"}
}]
}
}
I also tried with 'Name' but no luck. If there is a script that helps achieving it. That also works.
Hi @Harsh
Please try using the user name, as shown here for Server / Data Center versions: https://confluence.atlassian.com/automation/advanced-field-editing-using-json-993924663.html
Perhaps also check the edit metadata to learn if the REST API supports removing users with rules. That is also described in that post.
Kind regards,
Bill
Hi @Bill Sheboy
I did already tried it but no success.
Both set/add and remove not working.
The field is multi user field and I want to update add and remove it based on component.
Example - If component = A
then Multi user field = ABC
if component = B
then multi user field = DEF
It can have both component A & B together as well. Assuming at any point if the components A is removed I only want user ABC to be removed and not DEF.
Thanks!
Rohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Would you please post images of your complete rule, the actions with the edits, and of the audit log details. Those may provide context to help explain what you are observing. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
I can share the audit log for sure.
The first one shows success when I use the JSON in EDIT Action as below. It says success but user is not added nor removed(else if condition)
FOR ADD:
{
"update": {
"customfield_14296": [{
"add": {"accountId":"12345"}
}]
}
}
FOR REMOVE:
{
"update": {
"customfield_14296": [{
"remove": {"accountId":"12345"}
}]
}
}
Secondly,
I get this error when I use JSON
ADD:
{
"update": {
"customfield_14296": [{
"set": {"id":"12345"}
}]
}
}
And I simply get INVALID JSON error when I use NAME instead of id/accountID.
I want to achieve to simply add the names/ID for the users in multi user field.
Hope this helps
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In that documentation article for advanced edit with JSON, it describes how to check the edit metadata. That will show which operations (add, remove, set) are supported for a field. Please check that to confirm what is possible.
If that does not help, you may need to work with your site admin to contact Atlassian Support for this one: https://support.atlassian.com/contact/#/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Harsh
I think on server its not accountId.
Cloud you try
{
"update": {
"customfield_14296": [{
"remove": "id":"user_id"
}]
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Marc Koppelaar
Thanks for the answer. But I have already this and I get the following error.
'Error while parsing additional fields. Not valid JSON.'
Just for info - customfield_14296 is a multi user field and have multiple users. Let assume 2. I want to remove both of them when the issue is edited.
Also, when using accountID, It shows success but the user is not removed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Harsh
Are these the same set of users, or random?
If its random then its almost impossible.
If its always the same users, you might want to look at creating a lookup table and then take actions, but, this will also be difficult if the list is set in a random order.
Based on what action would user be removed and which users need to be removed?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Marc Koppelaar
I tried with script runner and it worked.
Also I tried other method based on smart value documentation - I edited the field with value {{null}}. In both cases it worked.
Although, to answer your question - we are setting the user automatically based on component.
Example - If component = A
then Multi user field = ABC
if component = B
then multi user field = DEF
It can have both component A & B together as well. But in this case the logic which I told above will fail, assuming at any point if the components A is removed I only want user ABC to be removed and not DEF. But if I am using {{null}} it is removing all users.
And hence I am looking for a way if there is a way to update/remove the user via json. I referred the Atlassian docs but of no use.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Harsh
If I look at the API options, for user related fields there is only the set option.
So this would mean that you would have to redefine you automation.
Are the components set on creation?
If so have a rule based on issue creation to set users based on component.
Have another rule that triggers on change on component, set validations based on options and set the user for the field.
Would that be an option?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, the components are not created on creation, it is just selected from the list.
And the automation should add the user..
I have tried with both SET and ADD. For Set it throws the error as mentioned above
For Add it says success but nothing happens.
"Have another rule that triggers on change on component, set validations based on options and set the user for the field" - I have added for both creation and updation both.
Thanks
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.
Let me try this for setting the users. But what should I do if I have to remove the users based on the condition?
I'll update you on this shortly
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Marc Koppelaar
Update, unfortunately it did work.
It throws an error - 'data was not an array'
customfied_14296 is User Picker (multiple users) type, does this mean it is not considering the field at all?
Thanks!
Rohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is no remove option via JSON.
See post from @Bill Sheboy
Checking the metadata show there is no remove or delete option via JSON.
You could contact Atlassian Support for this one: https://support.atlassian.com/contact/#/
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.