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

Parents
  • 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

  • 0 オフライン in reply to Gopikrishnan

    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) :-)

  • 0 オフライン in reply to Breton

    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

  • Assuming below example:

    - itmSource1 (generation = 1, Is_released = 0, is_current = 0) linked to Relation 1
    - itmSource1 (generation = 2, Is_released = 0, is_current = 0) linked to Relation 2
    - itmSource1 (generation = 3, Is_released = 1, is_current = 0) linked to Relation 3
    - itmSource1 (generation = 4, Is_released = 0, is_current = 1) linked to Relation 4

    Below Query Output is Relation 3
    <AML>
    <Item action="get" type="Part BOM">
    <source_id>
    <Item action="get" type="Part" orderBy="generation" where="[Part].is_released ='1' AND is_current ='0'">
    </Item>
    </source_id>
    </Item>
    </AML>

    Below Query Output is Relation 4
    <AML>
    <Item action="get" type="Part BOM">
    <source_id>
    <Item action="get" type="Part" orderBy="generation" where="[Part].is_released ='0' AND is_current ='1'">
    </Item>
    </source_id>
    </Item>
    </AML>

    Below Query Output is Relation 1 and Relation 2
    <AML>
    <Item action="get" type="Part BOM">
    <source_id>
    <Item action="get" type="Part" orderBy="generation" where="[Part].is_released ='0' AND is_current ='0'">
    </Item>
    </source_id>
    </Item>
    </AML>

  • 0 オフライン in reply to Gopikrishnan

    hello, my context is like that

    - itmSource1 (generation = 1, Is_released = 1, is_current = 0) linked to Relation 1
    - itmSource1 (generation = 2, Is_released = 1, is_current = 0) linked to Relation 2
    - itmSource1 (generation = 3, Is_released = 1, is_current = 0) linked to Relation 3
    - itmSource1 (generation = 4, Is_released = 0, is_current = 1) linked to Relation 4


    Because I "validate" my ITEM each time before revising.
    So you have Is_released = 1 severla time

  • 0 オフライン in reply to Breton

    Hi,

    If this is the case, below query will give the Relation1, 2 and 3

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

    However, if you want only Relation 3 then try with below 

    <AML>
    <Item action="get" type="Relation">
    <source_id>
    <Item action="get" type="itmSource" where="[itmSource].is_released ='1'" orderBy="generation DESC" maxRecords="1">
    <generation condition="gt">0</generation>
    </Item>
    </source_id>
    </Item>
    </AML>

Reply
  • 0 オフライン in reply to Breton

    Hi,

    If this is the case, below query will give the Relation1, 2 and 3

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

    However, if you want only Relation 3 then try with below 

    <AML>
    <Item action="get" type="Relation">
    <source_id>
    <Item action="get" type="itmSource" where="[itmSource].is_released ='1'" orderBy="generation DESC" maxRecords="1">
    <generation condition="gt">0</generation>
    </Item>
    </source_id>
    </Item>
    </AML>

Children
No Data