Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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 Dec 13, 2021

@Justin Mele 

Where are you adding the script?

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

Best,

Fadoua

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 Dec 13, 2021

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

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

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

image.png

Fadoua Community Leader Dec 14, 2021

Please add an initializer 

define both dropdown 

add a condition getActionName == "Create"

dropdownfield.setFormValue(null)

Fadoua Community Leader Dec 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 

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

Sorry wrong post.

Ok @Justin Mele 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 Dec 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 Justin Mele likes this

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

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 Dec 15, 2021

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

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

Best,

Fadoua

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 Dec 15, 2021

Let me check then get back to you

Like Justin Mele likes this
Like Fadoua likes this
Fadoua Community Leader Dec 15, 2021

@Justin Mele 

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
DEPLOYMENT TYPE
SERVER
TAGS
Community showcase
Published in Jira Software

👋 Looking for 15-20 volunteers to test Atlassian training content

Hi everyone! Are you interested in beta testing Atlassian University’s newest (unreleased!) training course? We’re looking for 15-20 volunteers to test our newest training course, Basic reporting...

812 views 24 28
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you