<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Query a nested CDT</title><link>https://community.appian.com/discussions/f/general/21333/query-a-nested-cdt</link><description>Hello everyone, 
 I kindly ask for a piece of advice doing this query. 
 I have a CDT called PurchaseOrderDetails and another one called ProductOrderedDetails. In this case, my PurchaseOrderDetails is pointing to an array of ProductOrderedDetails, like</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Query a nested CDT</title><link>https://community.appian.com/thread/83282?ContentTypeID=1</link><pubDate>Thu, 01 Jul 2021 23:34:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6c7bf837-4e65-4903-9143-40df96aa0cc7</guid><dc:creator>Acacio Barrado</dc:creator><description>&lt;p&gt;Hi Marta,&lt;/p&gt;
&lt;p&gt;What would be the result of this query:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!queryEntity(
      entity: cons!P2P_POINTER_ENT_PRODUCT_ORDERED_DETAILS,
      query: a!query(
        logicalExpression: a!queryLogicalExpression(
          operator: &amp;quot;AND&amp;quot;,
          filters: {
            a!queryFilter(
              field: &amp;quot;productOrdered.productOrderedId&amp;quot;,
              operator: &amp;quot;=&amp;quot;,
              value: ri!productOrderedId
            )
          }
        ),
        pagingInfo: a!pagingInfo(startIndex: 1, batchSize: - 1)
      )
    ).data&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Query a nested CDT</title><link>https://community.appian.com/thread/83215?ContentTypeID=1</link><pubDate>Thu, 01 Jul 2021 09:34:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f4dedec3-c2c2-4edb-b752-4a085dd5c926</guid><dc:creator>Marta</dc:creator><description>&lt;p&gt;Hi Acacio,&lt;/p&gt;
&lt;p&gt;Thanks for the information.&lt;/p&gt;
&lt;p&gt;Our PurchaseOrder (Parent) has the possibility to have many (child array) ProductOrdered.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m able to get the information regarding both, but whenever I query the child via expression rule, I never get a reference to the parent.&lt;/p&gt;
&lt;p&gt;For example, using this code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;if(
  rule!P2P_isNullOrEmpty(ri!productOrderedId),
  null,
  cast(
    &amp;#39;type!{urn:com:appian:types:P2P}P2P_ProductOrderedDetails?list&amp;#39;,
    a!queryEntity(
      entity: cons!P2P_POINTER_ENT_PRODUCT_ORDERED_DETAILS,
      query: a!query(
        logicalExpression: a!queryLogicalExpression(
          operator: &amp;quot;AND&amp;quot;,
          filters: {
            a!queryFilter(
              field: &amp;quot;productOrderedId&amp;quot;,
              operator: &amp;quot;=&amp;quot;,
              value: ri!productOrderedId
            )
          }
        ),
        pagingInfo: a!pagingInfo(startIndex: 1, batchSize: - 1)
      )
    ).data
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m able to retrieve the information regarding a specific ProductOrdered, but I never get a reference to the parent.&lt;/p&gt;
&lt;p&gt;My goal is to be able to retrieve the PurchaseOrder number via a ProductOrdered.&lt;/p&gt;
&lt;p&gt;Nevertheless, I do have a reference to the parent in the database:&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/11/pastedimage1625132081802v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I just can&amp;#39;t seem to retrieve the info via expression rule.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Query a nested CDT</title><link>https://community.appian.com/thread/83204?ContentTypeID=1</link><pubDate>Thu, 01 Jul 2021 03:15:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d70ccdff-d3fc-49b1-aa63-ace708625fe7</guid><dc:creator>Acacio Barrado</dc:creator><description>&lt;p&gt;Hi Marta,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Im not sure if&amp;nbsp; fully understood your scenario&amp;nbsp;but seems to me that what you described is correct. In your&amp;nbsp;&lt;span&gt;PurchaseOrderDetails&amp;nbsp;you will have and column called productOrdered that should have the PK from the&amp;nbsp;ProductOrderedDetails.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As you can see in the link that you attached in your post, you can create a normal queryEntity using the Pk of the&amp;nbsp;PurchaseOrderDetails&amp;nbsp;and in the return of this query you will receive all the&amp;nbsp;ProductOrderedDetails related.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;To access the data in there you can use index or dot notation in the&amp;nbsp;productOrdered.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Please correct me if I did not understood your scenario.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Acacio B.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>