Filtering Items by Item Type Name
Copy
You can use thexPropertyContainerItemItemType propertyto filter items by item type.The @conditionand @id attributes enable you to filter items by their type names, as shown in the following example:
<AML>
<Item type="xPropertyContainerItem" action="get">
<xp-cost>100</xp-cost>
<itemtype condition="in" by="id">
<Item type="ItemType" select="id">
<name condition="ne">Part</name>
</Item>
</itemtype>
</Item>
</AML>
The previous AML statement generates the following SQL:
SELECT … FROM [xPropertyContainerItem]
WHERE itemtype IN (SELECT id FROM secured.[ItemType] WHERE name <> ‘Part’)
In this case the:
- condition="in” attribute tells the server that it is required to filter using a subquery.
- by="id” attribute indicates which property has to be used from the subquery for filtering.
- Secured function has to be used in the subquery.
You can use the condition="in” by="…" attributes not only for the “itemtype” property of a poly item, but for ANY property of ANY item type.
For instance, Item Type A has a ‘weak’ reference to item type B not through B.id but through B.name. Item type A has a property reference_to_b which is a value of (unique) name of an item of type B. Now I want to use AML to find all items of type A that reference items of type B which have cost > 10. Then I can issue the following AML:
<Item type="A" action="get" select="…">
<reference_to _b condition="in" by="name">
<Item type="B" action="get" select="name">
<cost condition="gt">10</cost>
</Item>
</reference_to_b>
</Item>