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.

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

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

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

  • Greetings!

    I am contemplating a similar scenario for a proof-of-concept. I've attempted numerous approaches without success. Please consider the following AML:

    <Item type="DomainReportEntities" action="get">
      <related_id>
        <Item type="ReportEntity" action="GetItemRepeatConfig">
          <item_type>
            <Item type="ItemType" action="get" />
          </item_type>
          <Relationships>
            <Item type="ReportEntityProperties" action="get">
              <related_id>
                <Item type="Property" action="get" />
              </related_id>
            </Item>
            <Item type="ReportEntityFilters" action="get">
              <related_id>
                <Item type="ReportEntityFilter" action="get">
                  <property>
                    <Item type="Property" action="get" />
                  </property>
                </Item>
              </related_id>
            </Item>
            <Item type="ReportEntityEntities" action="get" repeatProp="related_id" />
          </Relationships>
        </Item>
      </related_id>
    </Item>

    I need to recursively pull the "ReportEntity" Item Type based upon the Item Type --> Relationship Type --> Item Type structure supported by the "ReportEntityEntities" Relationship Type.

    The results currently returned are correct at the parent, but there is no recursion / expansion into the child item's "item_type" property or relationships.

    Any insight is greatly appreciated!

  • I was able to get this working thanks to a former colleague that is now a Professional Services Solution Architect for Aras.  For future reference, the working AML is as follows:

    <Item type="ReportEntity" action="GetItemRepeatConfig" id="{@id} select="id,item_type">
      <item_type>
        <Item type="ItemType" action="get" select="id,name" />
      </item_type>
      <Relationships>
        <Item type="ReportEntityProperties" action="get" select="id,related_id">
          <related_id>
            <Item type="Property" action="get" select="id,name,data_type" />
          </related_id>
        </Item>
        <Item type="ReportEntityFilters" action="get" select="id,related_id">
          <related_id>
            <Item type="ReportEntityFilter" action="get" select="condition,property,value">
              <property>
                <Item type="Property" action="get" select="id,name,data_type" />
              </property>
            </Item>
          </related_id>
        </Item>
        <Item type="ReportEntityEntities" repeatProp="related_id" select="id,related_id" repeatTimes="0" />
      </Relationships>
    </Item>

    This does lead to me to one additional question: Is it possible to nest GetItemRepeatConfig within a larger AML structure, something along the lines of the following?

    .

    .

    .

    <Item type="DomainReportEntities" action="get" select="id,related_id" id="{@id}">
      <related_id>
        <Item type="ReportEntity" action="GetItemRepeatConfig" select="id,item_type">

    .

    .

    .

    Thanks in advance!