Show/hide field in form depending on another selection

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 Behnke Community Champion Sep 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
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,950 views 19 22
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you