Forums

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

Update multiselect custom field using Automation for JIRA

Deleted user November 6, 2020

How do I add value to a multiselect property using Automation for JIRA.

Setting an initial value using JSON is easy and works:

{"fields": {"Revenue Groups": [{ "value" : "Rev. Group 1"}]}

 

Adding an extra is a lot harder. I've tried the following (and other solutions) but without success.

{    "fields": {"Revenue Groups": [{ "value" : "Rev. Group 2"},       {{issue.customfield_13100.asJsonObjectArray("value ")}}]
}
}

1 answer

1 accepted

4 votes
Answer accepted
Kian Stack Mumo Systems
Community Champion
November 6, 2020

Hello Andre,

I was able to get mine work by adding the following to the Advanced Edit section of the automation. In my case, I had a multi select (customfield_10037) with values, 1,2,3,4,5,6.

{
"update": {
"customfield_10037" : [
{
"add": {
"value":"2"
}
}
]
}
}
Deleted user November 6, 2020

Hi Kian,

Thanks a lot. Works like breeze......

I've an additional question. Where can I find documentation on the operations 'add', 'remove' and 'set'. I'm wondering if there are more options. Starting from the following URL (https://confluence.atlassian.com/automation/advanced-field-editing-993924663.html) I can find a lot info but nothing related to operations as mentioned.

 

Cheers,

Andre

Claire Berry
Contributor
July 6, 2021

@Kian Stack Mumo Systems 
Hi Kian, does this work with insight multiple custom fields?

I am trying to use automation to add insight values to an insight custom field that is configured to be multiple. 

I added:

{
"update": {
"customfield_32970" : [
{
"add": {
"key" : "PPBCMDB-275620"
}
}
]
}
}


But I am getting some errors in the automation:
PPBSR-3588 (data was not an array (customfield_32970))
Even though the field is configured to be Multiple

Like Zac Boyd likes this
Zac Boyd
Contributor
December 19, 2022

@Claire Berry 

Hey Claire, 

Did you end up finding a solution to your Insight automation error ?

I am receiving the same error. (data was not an array) 

Your post has been the only one I've found attempting this

Like Elena Lurye likes this
Erik Huisman
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 25, 2023

@Zac Boyd @Claire Berry @Elena Lurye 

Dear all,

I ran into the same problem when I used the example of Claire in which she used: "add": {"key": ...

So I looked at the example of Kian where he used: 

"add": {"value": ...

And that did the trick!!

Although the field may be used as "key"-field, use the (restricted?) word "value" and then it seems to work. It also works with:

"remove": {"value": ...

 

Kind regards,

Erik

Claire Berry
Contributor
May 2, 2023

Yes, I also eventually got this to work with the below...

{

  "update": {

    "customfield_12345" : [{"add": [{"key" : "ABC-123"}]}]

  }

}

Like Markus Hartmann likes this
Marcel Rossouw
Contributor
February 9, 2024

@Kian Stack Mumo Systems Anybody know how to target a customfield drop down value to amend (reset) when needing to change back from an existing value of either "Yes" / "No" back to nothing (blank) i.e None?
Having a value: (blank) or null or none causes an error in the advanced Json, it's a single select custom field or is it about removing the actual value and then it essential has no value?

Claire Berry
Contributor
February 9, 2024

Can't you just do something like the below to clear a value from a single select custom field?



eg1.png

Marcel Rossouw
Contributor
February 9, 2024

Thanks for the response @Claire Berry but unfortunately I'm having to used the advanced section due to my custom field not even appearing in that list to choose from in the first place. From what I can tell, because it is a required field, it cannot be reverted as it is expecting either value available (Yes / No). It's default is 'None' because it hasn't been selected as a required value yet. This only get's forced on the user when transitioning or amending something else on the ticket. This required field was added after the fact on existing tickets.

Claire Berry
Contributor
February 9, 2024

@Marcel Rossouw is your field a regular since select list or an insight/asset custom field?
I am not sure why the field doesn't show in the drop down for you, that's strange. I can find fields in project automation to clear which are set as required. And I have tested the removal of this as per my screenshot previously and it works.

For single select lists, it looks like the only JSON it supports is 'set'

https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#:~:text=For%20example%2C%20to%20set%20the%20Single%20Select%20field%20to%20green%20during%20an%20edit%2C%20you%20can%20use%20the%20following%20JSON%3A

eg. (where 'Read' is an option in the select list to remove):

{
   "update": {
      "customfield_30904": [
         {
            "set": {"value": "Read"}
         }
      ]
   }
}


This doesn't appear to accept "None" or an empty string ""

Marcel Rossouw
Contributor
February 9, 2024

I figured it out. Because it's a required field - it would not allow a value other than one of the requires values (which makes sense). I had to make the field unrequired and then used this in my automation and it worked:

{
"update": {
"customfield_XXXXX": [{"set": {"value": null}}]
}
}

And that removes any predefined value

Claire Berry
Contributor
February 9, 2024

null is one thing I didn't try :) 
However this still doesn't work for me when I test it.. regardless if the field is required or not.
Maybe we are on different versions and it's available where you are.
Glad you got it sorted though

Marcel Rossouw
Contributor
February 9, 2024

To answer you from earlier, the field I'm targeting is a single select value dropdown field. (customfield)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events