Forum Discussion

ARAS_User's avatar
ARAS_User
Ideator I
6 years ago

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.

9 Replies

  • 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

    • ARAS_User's avatar
      ARAS_User
      Ideator I

      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>

      • christopher_gillis's avatar
        christopher_gillis
        New Member

        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