28 Apr’17

D365 SalesRetrieve data using same data type fields from different entities

Introduction:

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.

Description:

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.

Solution:

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/

Account:

Contact:

Query:

<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" />
        </link-entity>
    </entity>
</fetch>

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.

Conclusion:

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

  • Reading more then 10K records in D3FOE OData API

    11 July’ 2018

    Introduction: We all know Dynamics 365 Finance and Operations has limitation of 10K records to be fetched at a time usi...

    Read more
  • Paging in D365 Customer Engagement v9.0

    10 July’ 2018

    Introduction: The Xrm.retrieveMultipleRecords method is used to retrieve a collection of records in Dynamics 365 Custom...

    Read more
  • Set up Dynamics 365 connection in Microsoft Social Engagement

    10 July’ 2018

    Introduction: This blog explains how to Set up Dynamics 365 connection in Microsoft Social Engagement. Steps to be follo...

    Read more
  • Voice of the Customer failed to install

    10 July’ 2018

    Introduction: Many people face issues in installing Voice of Customer solution on v9 environment and trying repeatedly ...

    Read more
  • Scribe Insight AX as a Web Service Find Block issue

    10 July’ 2018

    Introduction: If we need to look up for any value from AX then we do it by using a Find Block in Scribe Insight Eg: Basi...

    Read more