Menu

filter

Creates a new Collection that contains another Collection's items that pass the specified condition.

Attributes

var

Required
Value type
EL-evaluated
Yes String No
Defines the name of the variable that will hold the filtered Collection. If all of the source Collection's items fail to pass the filtering condition, the variable's value will be an empty Collection.
value

Required
Value type
EL-evaluated
Yes Collection Yes
The resolved Collection value is the source Collection whose contents are filtered. This source Collection will not be modified in any way.
where

Required
Value type
EL-evaluated
Yes String No
Specifies the EL-expression that serves as the filtering condition. This expression is evaluated for every item in the source Collection, and all of them for which this expression evaluates into a Boolean true pass the filter and are included in the result.

In this expression the currently checked Collection item can be accessed with the variable name defined in itemName (or "x" if that attribute is undefined).

The resolved value of this attribute being an empty String or an invalid expression is considered an error.
itemName

Required
Value type
EL-evaluated
No String Yes
This attribute can be used to specify the name of the variable representing the source Collection's item in the EL-expression specified in where.

If left undefined, the name of the item variable will be "x".

Examples

Filtering a Collection of Salesforce query results:

<query var="lineItems" select="SELECT Id, Name, ListPrice, Quantity FROM OpportunityLineItem WHERE OpportunityId='${mainOppId}'">
<filter var="lowQuantity" value="${lineItems}" itemName="lineItem" where="${lineItem.Quantity < 10}">

You can also continue to filter the result of a previous filtering further:

<filter var="lowerQuantity" value="${lowQuantity}" itemName="lineItem" where="${lineItem.Quantity < 5}">

Comments

0 comments