Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

With Scriptrunner Behaviour - hide a field based on the values of a cascading field

Hi all,

 

I want to hide customfield_31613 when the values of the cascading field customfield_32216 are "a" and "b" (parent value and child value) respectively.

I'm using Behaviours for it, my current code:

def listField = getFieldById("customfield_32216")
def hiddenField = getFieldById("customfield_31613")

// get cascading list value (parent and child)
String listString = listField.getValue()
// if cascading list matches one of two selections, hide the Due Date OPS field
if ( listString == ["a", "b"]) {
hiddenField.setHidden(true)
}

 

It doesn't work. Can you tell me where I did wrong?

 

Thank you,

Duong

1 answer

1 accepted

Hi @anarcon GmbH,

If you wanted to hide a field based on a cascade list value using behaviour, you could try this script to hide the field:

//get the custom field details
def customField = getFieldByName("Cascade1")
def custField = getFieldByName("Select1")
//get the cascade field value
def cfAValue = customField.value as List

//for debug purpose
log.warn "cfAValue: " + cfAValue

if (cfAValue) {

//Size at least 2 [parentValue, childValue]
if (cfAValue.size()>1) {
//The 1st value will be your parent value, and the 2nd value will be your child value:
def parentValue = cfAValue.get(0)
def childValue = cfAValue.get(1)

//For debug purpose
log.warn "cfAValue: ${cfAValue}"
log.warn "parentValue: ${parentValue}"
log.warn "childValue: ${childValue}"

if(parentValue == "A" && childValue == "B"){
custField.setHidden(true)
} else {
custField.setHidden(false)
}
}
}

 I hope this able to help you with your requirement.

Hi @Amir Mustapha _Adaptavist_ ,

 

Thank you for your answer, it worked!

One problem though: when we change the cascade field values back to empty while creating the issues, the hidden field doesn't show up again. Do you know how to fix this?

Hi @anarcon GmbH,

From the sample script provided, if it meets the condition, you will setHidden(true) else you should also set the value to setHidden(false) from this sample condition to make the field reappear:

if(parentValue == "A" && childValue == "B"){
custField.setHidden(true)
} else {
custField.setHidden(false)
}

 I hope this able to answer.

Suggest an answer

Log in or Sign up to answer
TAGS

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