Search code examples
xmlcrmmicrosoft-dynamicsfetchxml

Dynamics CRM Fetch XML Return Customer Record


I'm creating a custom report for Dynamics CRM 2011 using BIDS. For a quote I have the potential customer type customerEntityName which returns either contact or account. How do I link this to the correct customer entity to pull address details etc. into the report?


Solution

  • You could try something like this; since it will only either be tied to an Account or a Contact, only one set of data will return values.

    <?xml version="1.0"?>
     <fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0">
       <entity name="quote">
        <attribute name="name"/> <attribute name="statecode"/> <attribute name="totalamount"/> <attribute name="customerid"/> <attribute name="quoteid"/> <order descending="false" attribute="name"/> -<link-entity name="account" alias="a_ce7d47f5258c4f20a6778ef6c718fa3b" link-type="outer" visible="false" to="customerid" from="accountid">
          <attribute name="address1_line1"/>
        </link-entity> -<link-entity name="contact" alias="quotecustomeridcontactcontactid" link-type="outer" visible="false" to="customerid" from="contactid">
          <attribute name="address1_line1"/>
        </link-entity>
      </entity>
    </fetch>