How can I make both fields in a Cascading Select required?

Jeremy Upright March 2, 2016

I have reviewed other topics, but not sure if it is as simple as adding the single line of code: cfValues.get("Application ID")?.keySet()?.size() == 2

I added the line above in the Simple scripted Validator, but it returns an error:

Cannot find matching method java.lang.Object#keySet().

Please check if the declared type is right and if the method exists.  Possible solutions: getAt(java.lang.String) @ line 1, column 1.


I presume this is because the only line of code I added was "cfValues.get("Application ID")?.keySet()?.size() == 2", (without quotes) but I wasn't sure if maybe there was something else I may be missing.

 

JIRA 7.1

ScriptRunner 4.2.0.5

 

Thanks,

Jeremy

1 answer

1 vote
Cristina_Abunei
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.
March 2, 2016

I think if you check for NULL(or a default value, like N/A) in your custom field value, you can  maike sure that both cascading lists are filled in. This is how it would look of you used a workflow condition:

def componentManager = ComponentManager.instance
def compAccessor = new ComponentAccessor()
def customFieldManager = compAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'cf_name'}
if(cf!=null){
def fieldConfig = issue.getCustomFieldValue(cf)
if(fieldConfig.toString().contains('NULL'))
passesCondition = false
else
passesCondition = true
}

The String value for a cascading select list looks like this : [0:val1, 1:val2]. It is respresented internally as a HashMap.

Suggest an answer

Log in or Sign up to answer