Hide/Show Field based on the value of the other field

Nombulelo Zizi October 3, 2017

 

Good day,

 

I'm tryingto hide fields based on the value of another field.

 

Below is my code and it's not doing anything.

 

import com.onresolve.jira.groovy.user.FormField

FormField dropDown = getFieldById("customfield_10306")
FormField fconditionA = getFieldById("customfield_10510")
FormField conditionB = getFieldById("customfield_10515")

if (dropDownValue.getFormValue() == "High")

{ //Yes

conditionA.setHidden(false)
conditionB.setHidden(true)

}
else
{
f conditionA.setHidden(true)
conditionB.setHidden(false)
}

 

Jira Service Desk 3.6.1

ScriptRunner 5.1.6

 

1 answer

1 accepted

1 vote
Answer accepted
Jenna Davis
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.
October 6, 2017

Hello,

You have some of your variables miss-named in the code you provided. I fixed that for you here:

def dropDown = getFieldById("customfield_10306")
def fconditionA = getFieldById("customfield_10510")
def conditionB = getFieldById("customfield_10515")

if (dropDown.getFormValue() == "High")
{ //Yes
fconditionA.setHidden(false)
conditionB.setHidden(true)
}
else
{
fconditionA.setHidden(true)
conditionB.setHidden(false)

You also shouldn't need to import FormField, assuming your doing this on a behaviour. Try using the code above as a behaviour on an initializer and let me know your results. If it still isn't working, please send me a screenshot of your behaviour. Also, if you have any questions please let me know!

Jenna

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events