Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Show/Hide field does not work when multiple options are selected

Thomas Hardin June 25, 2018

Good morning,

I have a behavior that uses the value of a multi-select drop down field to show another text field when selected, however; when any other value in the multi-select field is also selected, the behavior does not work.   

Any ideas on what I can do to correct this?

def accessPoints = getFieldByName("Access Points")
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def accessPointsField = customFieldManager.getCustomFieldObject(accessPoints.getFieldId())
def accessPointsConfig = accessPointsField.getRelevantConfig(getIssueContext())
def accessPointsOptions = optionsManager.getOptions(accessPointsConfig)
def other = getFieldByName("Other, explanation required access")


if (accessPoints.value == "Other (add detail to access request explanation)") {
 other.setHidden(false)
} else {
other.setHidden(true)
}

I'm sure it is something simple. I just can't seem to figure it out.

 

Thanks!

1 answer

Suggest an answer

Log in or Sign up to answer
1 vote
Danyal Iqbal
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.
June 25, 2018
accessPoints.value.contains("Other (add detail to access request explanation)") 

Try this.

Thomas Hardin June 25, 2018

It did not like that option:other error.png

Roland Holban (Adaptavist)
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.
June 25, 2018

You can ignore that error.

Groovy is a dynamic language, which means all method and property names are looked up when your code is run, not when it’s compiled, unlike Java. Because of this, the static type checker is not always correct. It is a best-efforts attempt to let you know if there are problems with your code.

Thomas Hardin June 27, 2018

Thank you both for the assist! This is working as expected now.

TAGS
AUG Leaders

Atlassian Community Events