Forum Discussion

dkinsley's avatar
dkinsley
Ideator I
2 years ago
Solved

Query help needed

Can someone help me with an AML query to find...

  • all of our parts in Innovator that have only one item in the EBOM
  • what revision sequence each part is assigned
  • what the single EBOM item part number is

Don

  • I went ahead and whipped up a quick method which you can add to your instance and execute to get all the parts with exactly 1 BOM Relationship:

    [embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:d4e06a2a-e62e-40f1-81f1-ba4ed2737dd7:type=text&text=var%20inn%20%3D%20this.getInnovator%28%29%3B%0D%0A%0D%0Avar%20parts%20%3D%20inn.newItem%28%22Part%22%2C%22get%22%29%3B%0D%0Aparts%20%3D%20parts.apply%28%29%3B%0D%0AList%3Cstring%3E%20relPartList%20%3D%20new%20List%3Cstring%3E%28%29%3B%0D%0AList%3Cstring%3E%20sourcePartList%20%3D%20new%20List%3Cstring%3E%28%29%3B%0D%0Afor%20%28int%20i%20%3D%200%3B%20i%20%3C%20parts.getItemCount%28%29%3B%20i%2B%2B%29%7B%0D%0A%20%20var%20currPart%20%3D%20parts.getItemByIndex%28i%29%3B%0D%0A%20%20var%20bomRel%20%3D%20inn.newItem%28%22Part%20BOM%22%2C%22get%22%29%3B%0D%0A%20%20bomRel.setProperty%28%22source_id%22%2CcurrPart.getID%28%29%29%3B%0D%0A%20%20bomRel%20%3D%20bomRel.apply%28%29%3B%0D%0A%20%20if%20%28bomRel.getItemCount%28%29%20%3D%3D%201%29%7B%0D%0A%20%20%20%20relPartList.Add%28bomRel.getProperty%28%22related_id%22%29%29%3B%0D%0A%20%20%20%20sourcePartList.Add%28currPart.getID%28%29%29%3B%0D%0A%20%20%7D%0D%0A%7D%0D%0A%0D%0Areturn%20inn.newResult%28%22Parts%20with%201%20Item%20in%20EBOM%3A%20%22%20%2B%20String.Join%28%22%2C%22%2CsourcePartList%29%29%3B]

    To utilize this, you can create a new method in Innovator, make sure it's a server method. Then once it's saved you should be able to run the following action (Run Server Method):

    The output should pop up. It'll be a list of IDs for all the parts that have exactly 1 BOM Relationship. After that you should be able to use that list for an AML Query using the idlist attribute.

    AJ

6 Replies

  • Hi Don,

    Is there a particular reason you're using AML for this task? Personally I'd write a short C# Method to gather this information.

    The flow would look something like:

    1. Get all Parts
    2. For each part, do a get on all Part BOM relationships with the same source ID
    3. Check how many relationships are returned in that get
    4. If count == 1, then we can use the related ID to get the information about the child part.
    5. Store in some list and return

    Let me know if that works!

    AJ

    • dkinsley's avatar
      dkinsley
      Ideator I

      AJ,

      Thank you for your reply.  Unfortunately, I am not familiar with C# or where I would even do that query.  

      • asebastian's avatar
        asebastian
        New Member

        I went ahead and whipped up a quick method which you can add to your instance and execute to get all the parts with exactly 1 BOM Relationship:

        [embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:d4e06a2a-e62e-40f1-81f1-ba4ed2737dd7:type=text&text=var%20inn%20%3D%20this.getInnovator%28%29%3B%0D%0A%0D%0Avar%20parts%20%3D%20inn.newItem%28%22Part%22%2C%22get%22%29%3B%0D%0Aparts%20%3D%20parts.apply%28%29%3B%0D%0AList%3Cstring%3E%20relPartList%20%3D%20new%20List%3Cstring%3E%28%29%3B%0D%0AList%3Cstring%3E%20sourcePartList%20%3D%20new%20List%3Cstring%3E%28%29%3B%0D%0Afor%20%28int%20i%20%3D%200%3B%20i%20%3C%20parts.getItemCount%28%29%3B%20i%2B%2B%29%7B%0D%0A%20%20var%20currPart%20%3D%20parts.getItemByIndex%28i%29%3B%0D%0A%20%20var%20bomRel%20%3D%20inn.newItem%28%22Part%20BOM%22%2C%22get%22%29%3B%0D%0A%20%20bomRel.setProperty%28%22source_id%22%2CcurrPart.getID%28%29%29%3B%0D%0A%20%20bomRel%20%3D%20bomRel.apply%28%29%3B%0D%0A%20%20if%20%28bomRel.getItemCount%28%29%20%3D%3D%201%29%7B%0D%0A%20%20%20%20relPartList.Add%28bomRel.getProperty%28%22related_id%22%29%29%3B%0D%0A%20%20%20%20sourcePartList.Add%28currPart.getID%28%29%29%3B%0D%0A%20%20%7D%0D%0A%7D%0D%0A%0D%0Areturn%20inn.newResult%28%22Parts%20with%201%20Item%20in%20EBOM%3A%20%22%20%2B%20String.Join%28%22%2C%22%2CsourcePartList%29%29%3B]

        To utilize this, you can create a new method in Innovator, make sure it's a server method. Then once it's saved you should be able to run the following action (Run Server Method):

        The output should pop up. It'll be a list of IDs for all the parts that have exactly 1 BOM Relationship. After that you should be able to use that list for an AML Query using the idlist attribute.

        AJ