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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,551,932
Community Members
 
Community Events
184
Community Groups

Show Custom Field if value from another Field is selected

Hi,

On Issue creation, I have a Cascading Select custom field that has a set of Values.

I am trying to run a script where if the 1st drop down has "Paypal" selected, another customfield called "PayPal Payee" should be shown.

If "Paypal" is not selected, the field should remain hiddem

After I created the script below, when selecting "Paypal", the fields still remains hidden

I cannot understand what I am doing wrong. 

Can someone please help me solve this issue?

script.PNG

1 answer

1 accepted

0 votes
Answer accepted
Joshua Yamdogo _ 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.
Aug 25, 2017

Hi Jason,

When creating a behaviour, the behaviour should be attached to the field that you want to track or check values from. In your case, you should put this behaviour on the Cascading Select custom field.

Your script isn't far off, but there's some things you need to change. First, Cascading Select Lists return a list of values whenever you call getValue() on the field. Example: ['Parent Option', 'Child Option']

So if you want to check the first dropdown, you'll need to access the first value of the list.

def cascadingField = getFieldById(getFieldChanged())
def cascadingValues = cascadingField.getValue()

def PaypalPayee = getFieldById("customfield_11906")
PaypalPayee.setHidden(true)

if (cascadingValues[0] == "Paypal") {
PaypalPayee.setHidden(false)
}

HI Joshua,

I did use the explenation above but now i have this error

code.PNGerror.PNG

Joshua Yamdogo _ 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.
Aug 31, 2017

Jason,

The static type checker is not always accurate. The behaviour should work regardless of the error. Try to use it. It worked for me.

Hi Joshua,

Unfortunately, it's not working.

When I open the create issue screen, "Paypal Payee Name" is still shown even if payment type has "None" selected.

create screen.PNG

I would like this to show only if "Paypal" is selected.

Any other ways I could achieve this? 

Thanks,
Jason

Joshua Yamdogo _ 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.
Sep 01, 2017

Jason,

It looks like you changed the script that I gave you? You have this in your screenshot:

if (PaymentType[0] == "Paypal")

when it should be this

if (cascadingValues[0] == "Paypal")

That's probably why you're getting that static type checking error, because you're trying to access an index of the object instead of the object's values.

I did exactly the above and works like a charm!

Thank you!

-Jason

Joshua Yamdogo _ 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.
Sep 04, 2017

Glad to hear Jason! :)

If you wouldn't mind, please accept my answer as the accepted answer so that others in the community can see the answer more easily.

Hi, I'm dealing with same issue. 

Code is completely the same.. What am I doing wrong? Can someone please answer. I would relay appreciate it. Can this be done in different way? 
I new to scriptRunner and gAnnotation 2020-05-28 144908.pngimage.pngroovy. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events