Forum Discussion

Breton's avatar
Breton
Ideator III
4 years ago

How to get relationship ITEM linked to latest released source ITEM in AML

hello,

The datamodel is simple : 

2 ITEM type = "itmSource" and "tmRelated"
Both are versionnable and with lifecycle 
The last state of lifecycle allows to set is_released to "1" on itmSource 


1 relation "Relation" between itmSource and itmRelated

Question : in AML, How to GET on relation all relationship  where source_id is the latest released state.

this AML request doesn't work fine :

<Item action='get' type='Relation'>
<source_id>
<Item type='itmSource' action='get' queryType="Released" queryDate="2022-02-11T23:59:59">
</Item>
</source_id>
</Item>


Do you have an idea ?
thanks

6 Replies

  • Hi Breton

    It depends on the situation. If you want only the latest released item based on the Relation then use below query

    Output of below query will be all the itemSource which is released and latest

    <AML>
    <Item action="get" type="Relation">
    <source_id>
    <Item action="get" type="itmSource" where="[itmSource].is_released = '1' AND [itmSource].is_current = '1'">
    </Item>
    </source_id>
    </Item>
    </AML>

    Thank You

    Gopikrishnan R

    • Breton's avatar
      Breton
      Ideator III

      Hello, Thanks for your answer but the AML respond is not compliant to the need :
      why :

      If you have 

      - itmSource1 (generation=1, Is_released=1, is_current=0 ) linked to Relation1

      - itmSource2 (generation=2, Is_released=0, is_current=1 ) linked to Relation2

      Regarding the example, I would like to retrieve Relation1 (linked to itmSource1 at Is_released=1).
      But  is_current=0 because is not the latest generation

      Normlaly, you can filter it by using queryType="Released", but not in sub AML request..(except I made an error) :-)

      • Gopikrishnan's avatar
        Gopikrishnan
        Accelerator II

        Hi Breton

        Assuming below example: When you use only is_released = "1", it is always pointing to itmSource1 in the query

        - itmSource1 (generation=1, Is_released=1, is_current=0 ) linked to Relation1 and you would like to retrieve Relation1 of this

        <AML>

        <Item action="get" type="Relation">
        <source_id>
        <Item action="get" type="itmSource" where="[itmSource].is_released ='1'">
        </Item>
        </source_id>
        </Item>
        </AML>

        Output of this query is 

        Relationship that connects itmSource in Released State or In Change State as source item and tmRelated as related item