I am currently trying to iterate over a list of ManagedObjects in event processing through a script.
It should check a condition for each ManagedObject
in the list and once it is true return that Object.
This is my script:
create expression ManagedObject getCurrentDepot(position, listObjects) [
for (i = 0; i <= listObjects.length; i++) {
var obj = listObjects[i];
var distance = distance(position.lat, position.lng, obj.Geofence.lat, obj.Geofence.lng);
if (distance <= obj.radius ) {
depot;
}
}
null;
];
I get the following error:
Error in statement mytest:statement_2! : Incorrect syntax near ';' at line 3 column 26
It complains about this line:
var obj = listObjects[i];
How can I correctly iterate over the list?