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

Jaydee Sendin December 4, 2017

Hi, I'm writting a script validator against a cascade select list and am getting this error 
"Cannot find matching method java.lang.Object#keySet()" 

here is my script: cfValues["Service - Category"]?.keySet()?.size() == 2 

where Service - Category is the name of my cascade select list. I followed the instructions as written in https://scriptrunner.adaptavist.com/5.2.1/jira/recipes/workflow/validators/simple-scripted-validators.html.

Looks like someone also experienced the same error here: https://community.atlassian.com/t5/Jira-questions/How-can-I-make-both-fields-in-a-Cascading-Select-required/qaq-p/26045

Any ideas as to whats wrong?

1 answer

0 votes
Thanos Batagiannis _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.
December 5, 2017

Hey Jaydee, 

So the cfValues["Service - Category"] will work only for a Simple scripted validator. 

The cfValues["Service - Category"]?.keySet()?.size() == 2 is correct and it will return true if there are exactly two options selected for your cascading select list (parent and child). 

If you describe me what you want to achieve then I believe I can help further. 

By the way the error you get in the UI is because of the static type checking and some time is safe to ignore it (jira logs will tell you the truth).

Jaydee Sendin December 5, 2017

Hi Thanos, 

I want to validate that both dropdowns in a cascading select list has a selected option (i.e. make both dropdowns required not just the 1st dropdown). 

Thanks

Thanos Batagiannis _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.
December 6, 2017

Hey Jaydee, 

So yeah the above should work for you as a  Simple scripted validator. 

Can you please attach a screenshot of your validator ?

Jaydee Sendin December 6, 2017

Hi Thanos, 

I ignored the error message and gave it a try. It works. Why is an error thrown this script? 
cfValues["Service - Category"]?.keySet()?.size() == 2

 

Thanks

Thanos Batagiannis _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.
December 6, 2017

Hey Jaydee,

Cool, the "errors" you get are because Groovy is a dynamic type language - for more info please visit https://scriptrunner.adaptavist.com/latest/jira/#_static_type_checking

Regards, Thanos

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events