resolver script checking no value of attribute; .length vs size()

IAM David Bantz dabantz at
Mon Apr 25 18:31:49 UTC 2022

This little script (inside the EdReadyRole attribute definition) to add a
default value if a dependent attribute did not assign value:

if (typeof EdReadyEntitlement != “undefined” && EdReadyEntitlement !=
null && EdReadyEntitlement.getValues().size !=0)
      {value = EdReadyEntitlement.getValues().get(0);

triggers this error if the attribute EdReadyEntitlement is in fact empty:

'EdReadyRole':Script did not run successfully
Caused by: java.lang.IndexOutOfBoundsException: Index 0 out of bounds
for length 0

A colleague smartly told me to replace .size() with .length, which does in
fact work without triggering the error. I do not really understand why,
given the existence of > 20 other instances of precisely parallel tests of
non-existence of dependent attribute in my resolver, accumulated over many
years. e.g.,

if (typeof uakStudentMAU != "undefined" && uakStudentMAU != null &&
uakStudentMAU.getValues().*size()* != 0)

if (typeof mauPrimaryAffiliation != "undefined" && mauPrimaryAffiliation !=
null && mauPrimaryAffiliation.getValues().*size()* != 0)


Should I replace all the .size() with .length condition?

*Feel free to administer virtual dope slap if accompanied by good

David St Pierre Bantz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the users mailing list