Show/hide field in form depending on another selection


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")

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") {

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

0 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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

200 views 1 18
Join discussion

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