Trying to get a field to hidden or not hidden depending on the selection of a Select List (Single)

Aaron Andrade December 13, 2021

We are trying to make it where A field is hidden on a screen unless one of the two highlighted choices are picked:

image.png

Here is the code that I used in behaviour:

image.png

1 answer

1 accepted

1 vote
Answer accepted
Fadoua
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 13, 2021

@Aaron Andrade 

Where are you adding the script?

Because for me it worked when I added my script under behaviours.

Best,

Fadoua

Aaron Andrade December 13, 2021

That's where I am adding them. Is mapping needed? I haven't used the behaviours before so I don't know if I am missing something.

Fadoua
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 13, 2021

You need to add the script to the field you are making selections on "customfield_11011"

Aaron Andrade December 14, 2021

It still hasn't worked, but I am running a re-index since fields have been added and the behaviour to see if that will help. If doesn't I will share a screen shot of how I have the behaviour setup.

Like Fadoua likes this
Aaron Andrade December 14, 2021

Still didn't work. Here is how I have the behaviour setup.

image.png

Fadoua
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 14, 2021

Please add an initializer 

define both dropdown 

add a condition getActionName == "Create"

dropdownfield.setFormValue(null)

Fadoua
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 14, 2021

Sorry now I see what you are trying to achieve.

I was under the impression you are hiding a field based on the option selected from a different field which is not the case

I am little bit confused. Sorry if you can provide more details 

Aaron Andrade December 15, 2021

So what I am trying to do is make "customfield_19915" visible only when one of the two highlighted options in the original post are selected. Then if any of the other options are selected then the field stays hidden. The reason for this is if the one of those two options are selected then the client needs to be notified and if not they don't.

Like Fadoua likes this
Fadoua
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 15, 2021

Sorry wrong post.

Ok @Aaron Andrade then your script is wrong.

Try Carmen's solution as suggested below, it is what I did in my script

https://community.atlassian.com/t5/Adaptavist-questions/Show-Hide-custom-field-based-another-another-field-value/qaq-p/963847

Fadoua
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 15, 2021

On your script you are getting a field Id and the same field you are getting its value which I think is wrong. However I am not a Groovy expert.

Like Aaron Andrade likes this
Aaron Andrade December 15, 2021

Thank you! I will give that code a try and see if we can get it to work. Thank you for all the help I appreciate it.

Like Fadoua likes this
Aaron Andrade December 15, 2021

Using the forum post you sent me and some documentation for scriptrunner I got the code to work see below the new code:

image.png

Like Fadoua likes this
Fadoua
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 15, 2021

It always makes my day when I get this kind of confirmations. Thank you for the update @Aaron Andrade !

If satisfied with the help provided please don't forget to accept my answer.

Best,

Fadoua

Aaron Andrade December 15, 2021

Would happen to know how to change the code to make it work for a multiselect list or know where to point me?

Like Fadoua likes this
Fadoua
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 15, 2021

Let me check then get back to you

Like Aaron Andrade likes this
Aaron Andrade December 15, 2021

Thank you!!

Like Fadoua likes this
Fadoua
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 15, 2021
Fadoua
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 15, 2021

@Aaron Andrade 

Why don't you try and to your if condition if (A == x && A == y) {

  script goes here

}

The same one you had earlier with the &&

Suggest an answer

Log in or Sign up to answer