PDA

View Full Version : Expression Engine Array[] evaluation


robertro
02-15-2007, 11:20 PM
I have an object that has an array as a member - lets call it Employees - and I need to evaluate the expression - Does one of the Employees in the array have a social security number of X.

I'm unable to work out how to do this - I'm unable to change the class that contains the member Employees as it's generated automatically.

Regards
Rob.

Aleks Seovic
02-16-2007, 04:23 AM
You can use first match selector expression to accomplish this:

Employees.^{ SSN == #x }

This expression will return first Employee instance whose SSN property is equal to x (note that I'm assuming x is passed as a variable, but you can hardcode it as well). If there is no match, expression will return null, so if you need boolean result (true if matching employee exists, false otherwise), you can do this:

Employees.^{ SSN == #x } != null

HTH,

Aleks