Show/hide field in form depending on another selection

Clayton Chancey September 18, 2017

Hi,

I am not exactly a Groovy expert. Nevertheless, I am trying my hand at getting this to work. I have a field for users to provide a business justification for the selection of a certain oracle role. I only want the field oracleJust to pop up in the create screen when field  oracleRole (a multi select list) is not empty.

I have a Behavior configured for the same field that is defined in my script as oracleRole, with an initializer function set as below:

import com.onresolve.jira.groovy.user.FormField
FormField oracleJust = getFieldById("customfield_17274")
oracleJust.setHidden(true)

And the inline script set as below:

import com.onresolve.jira.groovy.user.FormField
FormField oracleRole = getFieldById("customfield_10531")
FormField oracleJust = getFieldById("customfield_17274")
if (oracleRole.getFormValue() == "FIN-FA_Asset Inquiry") {
oracleJust.setHidden(false)
}

I have the behaviour mapped to the correct project. When I navigate to the create screen of that project, the initializer is doing it's job (oracleJust is hidden) but the inline is not. When I select a value from oracleRole, the dependent field is not showing. What am I doing wrong?

1 answer

1 vote
Steven F Behnke
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.
September 18, 2017

Where did you set the script under the line "And the inline script set as below"? Usually the answer is "log the value and result in your code":

log.warn "Log results (Hello mom!):\nOracle Role: ${oracleRole.getFormValue()}\nComparison results: ${oracleRole.getFormValue() == 'FIN-FA_Asset Inquiry'}"

I usually use the "toLowerCase()" String method as well, just to be a little easy going. :p

Suggest an answer

Log in or Sign up to answer