Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Clearing a text custom field if cascading child is empty when editing the issue.

Joel Batac
Contributor
January 12, 2023

HI,

 Im trying to clear a text field based on cascading's child option (if it is none). I tried using count (List) if is it less than 2, empty it. I tried getting the empty value using (?). And even getting the string value (.contains) but to no avail.

 

Here's what I have

 

def investmentClass = getFieldById("customfield_69820")
def requestClassification = getFieldById("customfield_69311")

Map selectedOptions = requestClassification.getValue() as Map
def parentOption = selectedOptions.get(0).toString()
def childOption = selectedOptions.get(1).toString()

//def cfAValue = requestClassification.value as List  ///tried to count the numbers options //if (cfAValue.size < 2) {entered

//if (!childOption){  ///tried if option is empyt/null
//if (childOption.contains("bank") || childOption.contains("Bank")) { ///checked if option has value

if (childOption == null ) {
investmentClass.setFormValue('')
} else {
investmentClass.setFormValue(childOption)
}

 

 

How can i achieve this? 

1 answer

0 votes
Tinker Fadoua
Community Champion
January 12, 2023

@Joel Batac 

The text field you are trying to clear is in a parent issue or a linked issue?

Joel Batac
Contributor
January 13, 2023

in the same issue.

Joel Batac
Contributor
January 13, 2023

i got it working by using  below.

 


if (childOption == !null) {
investmentClass.setHidden(true)
investmentClass.setFormValue(childOption)
} else {
investmentClass.setFormValue('')
investmentClass.setHidden(true)
}

Like Tinker Fadoua likes this
Tinker Fadoua
Community Champion
January 14, 2023

Nothing rewarding than finding the solution yourself. Glad you were able to get it done!

All the best,

Fadoua

Suggest an answer

Log in or Sign up to answer