Filtering Array Attributes in Case Views
When filtering case views, some of the attributes in the case class may be arrays.
If the attribute is an array, its name is followed by [ ] characters in the case view list. For example:
When you are filtering an array, or an item in an array, a field appears next to the array name on the Filter dialog. For example:
The field appears for most operators, like Equal, Not Equal, Greater Than, Null, and so on (there are some exceptions that are described below). The valid entries for this field are:
- ANY - This causes the filter to return the cases in which any of the items in the array match the specified criteria.
- ALL - This causes the filter to return the cases in which all of the items in the array match the specified criteria.
- An index number - This causes the filter to return the cases that match the specified criteria at that index number (zero based).
Nested Arrays
A case view filter can also included nested arrays. For example:
This nested-array filter returns the cases in which any contactNames array, in any lineItems array, contains the name “Baker”. For example:
Returning Cases Based on Number of Members in an Array
When you are filtering on an array attribute, a number of Size... operators are available:
These operators allow you to specify that cases be returned that have a certain number of members in the array.
For example, this filter returns the cases for which the lineItems array contains more than 10 members:
Using Tags in Compound Expressions for an Array
You can use tags in filter expressions to build more complex compound expressions. Tags are used when you want to stipulate that one or more of the compound expressions are to evaluate the same members of the array, or different members of the array.
Tags only make sense when you are building compound expressions.
A tag is entered in the array field on the Filter dialog by entering a $ character followed by a letter (a-z), optionally followed by additional letters or integers. For example:
The tag value following the $ is arbitrary, although each tag value represents a unique member of the array.
Examples best illustrate this.
Assume the following represents a single case, which represents an order. The order contains two items, each represented by a lineItems array:
And you want a filter that returns cases in which one lineItem has quantity = 1000 and a different lineItem has partNum = HH2886.
If you built the following filter, it would not return the case (order) because it would require a single lineItem to match both conditions:
You could, however, use tags in the following way:
Because each of these expressions have different tags ($a and $b), the quantity attribute must equal 1000 in one member of the array, and the partNum attribute must equal HH2886 in a different member of the array, all within the same case for the case to be returned.
To extend the previous example, assume you want the cases returned in which one lineItem matches:
and another lineItem matches:
You would use the following filter expression:
Notice that the first two expressions contain “$x” as the tag, which means that those must match in the same lineItem. And the second two expressions contain “$y” as the tag, which means that those two must match in the same lineItem.