28 Apr’17

Dynamics 365, EnterpriseRetrieve data using same data type fields from different entities


We have various methods to query CRM like, “query expression”, “fetch expression” and “LINQ”. If we want to query data of two different entities, then we should have relationship between entities otherwise you will not get data. In case you want to process data of two different entities which are not related to each other then what to do.

We can achieve this using fetch Expression in with the common field data type.


We had a requirement where we wanted to get the data from two different entities which were not related to each other but both of them had common field Email Address. So we can query the CRM using Fetch expression by providing from field and to field which will connect to each other.


To demonstrate this how it works I have tested it with account and contact entities as an example. We are testing it with “email address”. To execute this query XRM tool box is used. You can download it from given link http://www.xrmtoolbox.com/




<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" >
    <entity name="contact" >
        <attribute name="fullname" />
        <attribute name="emailaddress1" />
        <order attribute="fullname" descending="false" />
        <link-entity name="account" from="emailaddress1" to="emailaddress1" alias="Account" >
            <attribute name="emailaddress1" />
            <attribute name="name" />

As you can see that we have linked contact and account on the basis of emailaddress1. Once you execute the query you will have all the records which are related to each other with same email id

As you can see there are more records matching with same email id on account and contact. So it returns all the records with the matching email id.


You can query CRM data of two different entities using the same data type fields.

Written by

Subhash Mahato

Technical Consultant

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.

Want to streamline your business processes?

  • This field is for validation purposes and should be left unchanged.

Recent Articles

  • Dynamics 365 Client Diagnostics

    15 March’ 2018

    Main cause of Performance Issues: Bandwidth and latency are the primary characteristics which affects the performance o...

    Read more
  • Closing Blind Shift in MPOS and CPOS in Dynamics 365 for Retail

    15 March’ 2018

    Manual For closing Blind shift in POS: Blind shifts terminate the currently ongoing shift and when logged in a new shif...

    Read more
  • Persistent Filters in the Power BI Service

    13 March’ 2018

    Introduction: The feature is finally release, and it is power BI has announced general availability of persistent filt...

    Read more
  • Cause and Solution for Scribe MSMQ not receiving Message from AX

    10 March’ 2018

    Issue: Microsoft Message Queuing (MSMQ) service running on Server might be unable to receive messages. Therefore, messa...

    Read more
  • User Privileges on SharePoint – D365 Document Integration

    10 March’ 2018

    Overview: Often, we wonder what could be wrong where we see a generic error on Documents in Dynamics 365. Something lik...

    Read more