How to fetch details of nested relationships using AML query?

I have a requirement like

Main Phase can have relationship with Activities and Phases, also Phases can have child phases

eg:

i want to get the id of all  activity (itemtype2) if i provide id  of main phase is provided ? A phase can have no activity also.

  • Hi Hyder,

    You can check out the first section of this blog post on special aml actions for an example how to perform a recursive AML query which should help you get all of the Activities that you're looking for. 

    Chris


    Christopher Gillis

    Aras Labs Software Engineer

  • I tried something similar like this. But did not provide any result .(I am using 12Sp3)

    <AML>
    <Item type="prj_Phase" action="GetItemRepeatConfig" select ="id" >
     <id>Test_id</id>
        <Relationships>
        <Item type="prj_Phase Activity" action="get" select="related_id" >
             <related_id>
             <Item type="prj_Activity" action="get" select="state,name" ></Item>
              </related_id>
        </Item>
        <Item type="prj_Phase Child_Phase" action="get" select="related_id" >
         <related_id>
                <Item type="prj_Phase" repeatProp="related_id" repeatTimes="0" action="get" select="id" >
                    <Relationships></Relationships>
                 </Item>
           </related_id>
         </Item>
       </Relationships>
    </Item>
    </AML>

  • Hello,

    The syntax for this action can be picky. Try using the syntax below instead.

    <AML>
        <Item type="prj_Phase" select="id" action="GetItemRepeatConfig" id="YOUR_PART_ID">
            <Relationships>
                <Item type="prj_Phase Child_Phase" select="related_id" repeatProp="related_id" repeatTimes="0" />
                <Item type="prj_Phase Activity" action="get" select="related_id(state,name)" />
            </Relationships>
        </Item>
    </AML>

    Note that for simplicity, I've also condensed the query for the prj_Phase Activity relationship. You can query for data from an item property by including an additional set of property names in parentheses inside of your select statement. In this example, I'm getting the state and name properties from the item stored in the related_id by using related_id(state,name). This extra bit isn't necessary for the GetItemRepeatConfig action, but minimizing the size of the queries you write can make it easier to work with them.

    Chris

  • Query is only finding "Activity" which are in parent Phase. It is not able to find Activity inside the 3rd level Child phase. There is no Activity in 2nd levels, only phases..See below representation

    Phase
    Activity1
    Activity2
    Phase 1
    Phase1a
    Activity3
    Activity4
    Phase1b
    Activity5
    Activity6
  • Hello,

    Could you post the AML that you're using now? I tested this in a local instance with a similarly formatted Part BOM and Part Document structure, but I was able to get all of the items I expected. 

    Chris

  • Thanks for the response

    Initially I had the below aml which gave me correct result for 3 levels .

    <AML>
        <Item type="Project" action="get" select ="name,id" >
            <id>${prj_id}</id>
            <Relationships>
                <Item type="Project Activity_Domain"  action="get" select="related_id" >
                    <related_id>
                        <Item type="prj_Phase" action="get" select ="name,id" >
                        <id>${phase_id}</id>                        
                            <Relationships>
                                <Item type="prj_Phase Activity"  action="get" select="related_id" >
                                    <related_id>
                                        <Item type="Activity" action="get" select="state,id,name"></Item>
                                    </related_id>
                                </Item>
                                <Item type="prj_Phase Child_Phase"  action="get" select="related_id" >
                                    <related_id>
                                        <Item type="prj_Phase "  action="get" select="name" >
                                            <Relationships>
                                                <Item type="prj_Phase Activity"  action="get" select="related_id" >
                                                    <related_id>
                                                        <Item type="Activity" action="get" select="state,id,name"></Item>
                                                    </related_id>
                                                </Item>
                                                <Item type="prj_Phase Child_Phase" action="get" select="related_id" >
                                                    <related_id>
                                                        <Item type="prj_Phase "  action="get" select="name" >
                                                            <Relationships>
                                                                <Item type="prj_Phase Activity"  action="get" select="related_id" >
                                                                    <related_id>
                                                                        <Item type="Activity" action="get" select="state,id,name"></Item>
                                                                    </related_id>
                                                                </Item>
                                                            </Relationships>
                                                        </Item>
                                                    </related_id>
                                                </Item>
                                            </Relationships>
                                        </Item>
                                    </related_id>
                                </Item>
                            </Relationships>
                        </Item>
                    </related_id>
                </Item>
            </Relationships>
        </Item>
    </AML>
    This AML always checks 3 levels which is not necessary. I wanted to optimize this. So i tried using repeatconfig. See below AML, but not giving same result as above. This is able to find Activity in 1st level
    <AML>
        <Item type="Project" action="get" select ="name,id" >
            <id>${prj_id}</id>
            <Relationships>
                <Item type="Project prj_Phase"  action="get" select="related_id" >
                    <related_id>
                        <Item type="prj_Phase" action="get" select ="name,id" >
                         <id>${phase_id}</id>  
                            <Relationships>
                                <Item type="prj_Phase Child_Phase" select="related_id" repeatProp="related_id" repeatTimes="0" />
                                <Item type="prj_Phase Activity" action="get" select="related_id(state,id,name)" />
                            </Relationships>
                        </Relationships>
                    </Item>
                </related_id>
            </Item>
        </Relationships>
    </Item>
    </AML>
  • Hello,

    It seems like you're just using a normal get action on prj_Phase instead of GetItemRepeatConfig. Can you try changing the action on that part of the AML?

    <AML>
        <Item type="Project" action="get" select ="name,id" >
            <id>${prj_id}</id>
            <Relationships>
                <Item type="Project prj_Phase"  action="get" select="related_id" >
                    <related_id>
                        <Item type="prj_Phase" action="GetItemRepeatConfig" select ="name,id" id="${phase_id}">
                            <Relationships>
                                <Item type="prj_Phase Child_Phase" select="related_id" repeatProp="related_id" repeatTimes="0" />
                                <Item type="prj_Phase Activity" action="get" select="related_id(state,id,name)" />
                            </Relationships>
                        </Relationships>
                    </Item>
                </related_id>
            </Item>
        </Relationships>
    </Item>
    </AML>

    Chris