**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") {
apc.setHidden(true)
}else if(severity.getValue() == "4 - Affects non-critical function (low impact)") {
apc.setHidden(true)
} else if(severity.getValue() == "3 - Affects non-critical function (high impact)") {
apc.setHidden(true)
}else if(severity.getValue() == "N/A"){
apc.setHidden(true)
}else {
apc.setHidden (false)
}
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is what I meant with that first lines... just to use some debug information
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,
I'm able to show/hide my sprint field accordingly
Shown because I selected "products"
Hidden because products or mobile are not selected:
What you have should work. Just make sure the spelling of those severities and field names are correctly matched in the code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Quick question do I want this behviour on the Multi Select List Field or the Analysis Provided to Client Field?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Got it to work! It was a simple wording issue that fixed it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.