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

This widget could not be displayed.
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 Friday in Jira

New 5k User Limit and Other Cloud Updates

Hi all! Lauren here from the Enterprise Cloud marketing team.  I have some exciting Cloud updates from #AtlassianSummit that I wanted to share. We want everyone in your organization to be ab...

92 views 0 3
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