2

Wondering if WA is capable of checking for objects in an array that may be null? I'm able to print the loop in the "try it out panel", but still get an error message in the panel as well:

Dialog node error

SpelEvaluationException when evaluating dialog node ID [node_28_1539296242898].

The syntax of condition [$childCtnList[$i] !=""] is valid, but cannot be evaluated.

Check that objects in expression are not null or out of bounds.

SpEL evaluation error: EL1025E: The collection has '2' elements, index '2' is invalid [1]

There are only 2 objects in the array so I'm wondering if when it gets to childCtnList[2] it doesn't know what to do?

Community
  • 1
  • 1
K Choi
  • 31
  • 1

2 Answers2

0

The main issue you have is that arrays start from 0. So if you have two items then you will have $childCtnList[0] and $childCtnList[1] only.

You can use $childCtnList.size() to get the array size and then have the loop continue while it is less than the size.

If you want to check for null values in the array, you can do the following:

!$childCtnList[$i]

It will return true if the object referenced is null.

Simon O'Doherty
  • 9,259
  • 3
  • 26
  • 54
0

And adding to @Simon response, it may be good to also check if the array itself is not null before checking its contents !$childCtnList