Forum Discussion

hadrien_guiducci's avatar
6 years ago
Solved

AML where condition based on keyed name

Hi community, I am trying to transform a where condition based on id into a where condition based on the keyed name or item_number Outside a where condition it would be < source _id> <Item...
  • cogres's avatar
    cogres
    6 years ago

    Hi,

    thanks for the clarification, I think I understand your issue. You want to "merge" relationships, ideally inside the AML of a Part you are merging. Personally, I try to avoid using the "merge" action as much as possible. I like to have control over what happens when and how, and a "create the item, but if it exists, edit it instead, but you won't really know either way" goes against that completely. Hence, I try to explicitly get the item and then either edit it (if it existed) or create a new one (if it didn't). That way I can also easily attach different logic to the two different events.
    In any case, if you want to use "merge", I would still strongly suggest to have at least two AML queries. One to edit or create the Parts and another one to edit or create the Part BOM relationships. If you do it this way, you will have the Aras IDs for PartA and PartB from your first AML query, so in your second one you can simply have a merge with a where clause like

    where="PART_BOM.SOURCE_ID='idOfPartA' AND PART_BOM.RELATED_ID='idOfPartB'"

    How do you run your import into Aras? If you are using C#, you might want to use the IOM.dll instead of AML, for more flexibility.
    If you absolutely must have everything in one AML, you need to look into the two links I posted in my previous reply to make a where clause like

    where="PART_BOM.SOURCE_ID in (SELECT id FROM innovator.PART WHERE ITEM_NUMBER = 'PartB')"

    work.

    Hope this helps,

    C

  • hadrien_guiducci's avatar
    6 years ago

    I asked the support and get another possibility [emoticon:c4563cd7d5574777a71c318021cbbcc8] more simpler that I will implement when we will have time.

    It's more efficient and exaclty what we needed to do.

    If you apply it several time it won't add a new relationship each time :

    <AML>

        <Item action='edit' type='Part' where="item_number='PartTest'">

              <Relationships>

                    <Item type = 'Part BOM' action='create'>

                         <related_id>

                              <Item type='Part' action='get'>

                                   <item_number>TestGraphProject_A</item_number>

                              </Item>

                         </related_id>

                    </Item>

                    <Item type = 'Part BOM' action='create'>

                         <related_id>

                              <Item type='Part' action='get'>

                                   <item_number>TestGraphProject_B</item_number>

                              </Item>

                         </related_id>

                    </Item>

              </Relationships>

        </Item>

    </AML>

    Thanks @jeanpierreSolorzano from support :)