Forum Discussion

lucas's avatar
lucas
Ideator I
5 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.

[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:8336f2cd-196d-4ebb-8979-eeead87b54f9:type=text&text=%3CAML%3E%0D%0A%3CItem%20action%3D%22get%22%20type%3D%22itemType%22%20select%3D%22name%22%20where%3D%22ItemType.name%20%3D%20%27ZFCcontrainteTemplate%27%22%3E%0D%0A%09%3Cname%3Epart%3C%2Fname%3E%0D%0A%09%3CRelationships%3E%0D%0A%09%09%3CItem%20type%3D%22property%22%20action%3D%22get%22%20select%3D%22value%2C%20label%22%20where%3D%22%5Bproperty%5D.label%20like%20%27z%25%27%22%20%2F%3E%0D%0A%09%3C%2FRelationships%3E%0D%0A%3C%2FItem%3E%0D%0A%3C%2FAML%3E]

[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:d50be430-1135-40a5-be6a-46672b9d79f9:type=text&text=var%20FCitemType%20%3D%20inn.newItem%28%22itemType%22%2C%20%22get%22%29%3B%0D%0A%2F%2F%20FCitemType.setProperty%28%22name%22%2C%22FCcontrainteTemplate%22%29%3B%0D%0A%2F%2F%20FCitemType.setAttribute%28%22select%22%2C%20%22name%22%29%3B%0D%0AFCitemType.setAttribute%28%22where%22%2C%20%22%5BitemType%5D.name%20like%20%27ZFCcontrainteTemplate%27%22%29%3B%0D%0A%0D%0A%0D%0Avar%20property%20%3D%20FCitemType.createRelationship%28%22property%22%2C%20%22get%22%29%3B%0D%0Aproperty.setAttribute%28%22select%22%2C%20%22label%22%29%3B%0D%0Aproperty.setAttribute%28%22where%22%2C%20%22%5Bproperty%5D.label%20like%20%27z%25%27%22%29%3B%0D%0A%0D%0Aconsole.log%28%22FCitemType%20before%20apply%3A%20%22%2BFCitemType.ToString%28%29%29%3B%0D%0AFCitemType%20%3D%20FCitemType.apply%28%29%3B]

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
      Ideator I

      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 

      • AngelaIp's avatar
        AngelaIp
        Ideator I

        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?