Setting a multi-select field with Automation

Nic Brough -Adaptavist-
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.
June 13, 2022

I have stumbled into a use-case that I don't quite seem to be able to do.

The simplified case that leaves out all the bits I think I've worked out is:

  • Imagine we have a field for "areas impacted".  It's a multi-select list with say 7 options, named after the colours of the rainbow.
  • Next we have some other fields that might have data, or be empty.
  • We want to do things like "if one field is empty, areas needs to have 'red' selected.  If the field 'Kermit' is not empty, areas needs to have 'green' selected..  If three or more of these fields are filled, areas needs to have 'blue' selected".

I know how to do all the "if" bits. 

I do not see how to create a list of options that need to be set or unset in the multi-select field, or how to then apply that list to it.

2 answers

1 accepted

3 votes
Answer accepted
Yvan Martin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 17, 2022

Hi Nic,

Developer from Automation here.

The best way I can think of would just be to use append/remove APIs when editing the issue, so when those particular IF checks happen you can then just do an action to append the particular field. We do have a "variable" action but it's not currently setup in a way that you can keep appending then do 1 final edit, you'll need to do multiple with your if conditions.

One way to do this if you just need add and not remove is to use a smart value to copy the current fields options, then add the new option e.g. {{issue.Multi Checkbox}}

Screen Shot 2022-06-17 at 8.06.46 pm.png

If you would like more flexibility there is add/remove API with multi issue fields but it's not something we support natively so you'll need to use the advanced option in the edit action mentioned in in https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/  . Here's an example that both adds and removes an option at the same time, you can also have multiple adds if you replace the remove word 

{
    "update": {
        "Multi Checkbox": [
                {
                        "add": {"value":"Option1"}
                },

                {
                        "remove": {"value":"Option2"}
                }
        ]
    }
}

Screen Shot 2022-06-17 at 10.39.25 pm.pngHope this helps.


Feel free to reach out to Atlassian support if you require additional assistance https://support.atlassian.com/.

Cheers.

0 votes
Ida Giersing February 28, 2023

Hi @Yvan Martin 

I'm trying to do something similar and can't get it to work – I was hoping you could help :) 

I need an automation that does the following: 

1. If the description of the issue contains the word "Danish" select "Danish (da-DK)" from a multi-select drop-down. 

2. If the description of the issue contains the word "Dutch" select "Dutch (nl-NL)" from the multi-select drop-down. 

Etc. with a bunch of other languages. But I need them to be accumulative. I've tried a few things and always end up with only the last listed language being selected in the multi-select. So it's like each step of the rule overwrites the previous one. 

I tried your first suggestion above, using the smartvalue {{issue.customfield_xxxxx}} and adding also the option to be added, but it doesn't work. 

Any tips?

Thank you!

Suggest an answer

Log in or Sign up to answer