get property list from item type, issue reading the result item
hello,
i want to get a list of names of propreties that start a certain way 'z%'. i've found aml that was supposed to do it, i' made an iom code to recrate that aml (actually creates the right aml). But what i get is only one item, so i want to know if the aml is actually good or if there is a specific way to get the properties from that one item i get.
<AML>
<Item action="get" type="itemType" select="name" where="ItemType.name = 'ZFCcontrainteTemplate'">
<name>part</name>
<Relationships>
<Item type="property" action="get" select="value, label" where="[property].label like 'z%'" />
</Relationships>
</Item>
</AML>var FCitemType = inn.newItem("itemType", "get");
// FCitemType.setProperty("name","FCcontrainteTemplate");
// FCitemType.setAttribute("select", "name");
FCitemType.setAttribute("where", "[itemType].name like 'ZFCcontrainteTemplate'");
var property = FCitemType.createRelationship("property", "get");
property.setAttribute("select", "label");
property.setAttribute("where", "[property].label like 'z%'");
console.log("FCitemType before apply: "+FCitemType.ToString());
FCitemType = FCitemType.apply();
thanks
lucas
Your result contains items of two ItemTypes. The parent itemtype (1 item) and the sub-itemtype (many items).
Try to filter your result with xpath:
Item myprops = yourresult.getItemsByXPath("//Item[@type='Property']");
You can throw a log entry with the amount of properties by using myprops.getItemCount();
And maybe use PropertyCondition instead of "Where" to apply the filter. Is more secure according to Aras:
Item myParts= this.newItem("Part", "get");
myParts.setAttribute("select", "item_number");
myParts.setPropertyCondition("item_number", "like");
myParts.setProperty("item_number", "C123%");