Forum Discussion

lucas's avatar
lucas
Creator II
4 years ago
Solved

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%");

7 Replies

  • 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%");

    • lucas's avatar
      lucas
      Creator II

      I've tried to get the properties objects using x path as you mentionned but i get an ItemCount = 0

      i do have some properties stating with z in my item type, if you have any idea why that doesn't work let me know,

      and i couldn't apply the filter through propertycondition without getting an error 

      • angela's avatar
        angela
        Catalyst II

        Is your Method JS or C#? and I am not sure, if ItemTypes names are case sensitive. Does it work better when you write them like in the database?