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
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for the sample code - it works great!
One additional question. I notice when the create screen is initially displayed, custField is visible. Once I select the first part of the cascading field, the custField becomes hidden. It's not visible again until the user selects the matching criteria.
How can I make the field hidden on create ... hidden until the user selects the matching criteria to make the field hidden.
Thanks!
Bridy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I figured it out right after the post, of course!
I made the following adjustment
if (cfAValue) {
... same code as above
} else {
custField.setHidden(true)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.