Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Trying to get a field to be hidden or not hidden depending on the selection of a Multi Select List

**Already asked this question for a Single Select List, that I got to work, but found out we can't change it to a single select and need to make it work for a Multi Select List**

We are trying to make it where a field is hidden on a screen unless one of the two highlighted choices are picked:


Here is the code that I got to work for the Single Select List in the behaviour Is there anything I can do to make it work for the Multi Select List?:

def apc = getFieldByName("Analysis Provided to Client")
def severity = getFieldById(getFieldChanged())

def selectedOption = severity.getValue() as String

if (severity.getValue() == "No Impact/Task") {
}else if(severity.getValue() == "4 - Affects non-critical function (low impact)") {
} else if(severity.getValue() == "3 - Affects non-critical function (high impact)") {
}else if(severity.getValue() == "N/A"){
}else {
apc.setHidden (false)

1 answer

1 accepted

0 votes
Answer accepted

What I like to do in this case is do something like this:

severity.setHelpText("$severity.value (${severity.value.getClass()})

This way, you'll see what you're working with based on what you select in your severity. I think you'll see an ArrayList of String values.

Then, you can simplify your code quite a bit.

Try this:

def apcVisibleWhenSeverities = [
'1 - Affects critical function (low impact)',
'2 - Affects critical function (high impact)'
def severityFld = getFieldById(fieldChanged)
def apcFld = getFieldByName("Analysis Provided to Client")
apcFld.setHidden(!severityFld.value.any{it in apcVisibleWhenSeverities})


Am I supposed to put the first line code in the behaviour with the other code? I tried the code and it did not work for me unfortunately


I am new to the whole behaviour piece of Jira and I am hoping that I didn't miss anything or set it up work.


Here is what I meant with that first lines... just to use some debug information

2021-12-17 09_34_44-Edit Behaviour_ test.png2021-12-17 09_36_15-Create Issue - JIRA Dev.png

This gives me some information about what type of data we get from fld.value.

Then when I convert the script I gave you to work with my situation and fieldnames,

2021-12-17 09_50_31-Edit Behaviour_ test.png

I'm able to show/hide my sprint field accordingly

Shown because I selected "products"

2021-12-17 09_52_56-Create Issue - JIRA Dev.png

Hidden because products or mobile are not selected:

2021-12-17 09_52_21-Create Issue - JIRA Dev.png

What you have should work. Just make sure the spelling of those severities and field names are correctly matched in the code.

Like Justin Mele likes this

Quick question do I want this behviour on the Multi Select List Field or the Analysis Provided to Client Field? 

Got it to work! It was a simple wording issue that fixed it.

Behaviours on a specific field are executed whenever that field is modified. So you'll want this behaviour code on the Severity field so it fires when you change the severity.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events