Dynamics 365 CRM Show/Retrieve Data of Grandparent Record

Requirement:

    We have a construct like entity1 - 1:n - entity2 - 1:n - entity3, and want to display data from entity1 in entity3 (form or list). 

Example:

     Opportunity 1:n Account

     Account 1:n Contact (Primarry Contact)

     Opportunity  no relationship with Contact (Primary Contact)

     So using Dynamics 365 CRM Advanced Find cannot retrieve fields of Contact to Opportunity list.

Solution:

      XrmtoolBox + FetchXML

  1. XML:     Download

      <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">

  <entity name="opportunity">

    <attribute name="name" />

    <attribute name="parentaccountid" />

    <filter type="or">

      <condition attribute="statecode" operator="eq" value="1" />

      <condition attribute="statecode" operator="eq" value="2" />

    </filter>

    <filter type="and">

      <filter>

        <condition attribute="actualclosedate" operator="last-x-months" value="8" />

      </filter>

    </filter>

    <order attribute="name" descending="false" />

    <link-entity name="account" from="accountid" to="customerid">

      <attribute name="primarycontactid" />

      <link-entity name="contact" from="contactid" to="primarycontactid">

        <attribute name="emailaddress1" />

      </link-entity>

    </link-entity>

  </entity>

</fetch>



     Result:



2. XrmToolBox:

  • FetchXML Builder:   Create XML

   

  • Export To Excel:   Export retrieve report to excel spreadsheet, work with FetchXML Builder




No comments:

Post a Comment