knowledgecenter-breadcrum

Knowledge Center

26 Apr, 2023

How to use FetchXml with link-entity in WebAPI D365 CE

Posted on 26 Apr, 2023 by Admin, Posted in Dynamics 365 Web Api Dynamics 365

How to use FetchXml with link-entity in WebAPI D365 CE Blogs

What is Link-Entity

1. To combine data from different records in your query you need to use the element.
2. Each needs 3 key pieces of information:

2.a. The entity types to link to

2.b. The attribute in the main entity to join from

2.c. The attribute in the another entity to join to

NOTE: If you have a many-to-many (N:N) relationship you can’t join the entities directly, you have to join via the intermediate “intersect” entity.

3. There are two types of link-types: inner and outer.

4. The Link-Entity syntax requires providing of an Alias using which the values of the attributes can be accessed from the result-set.

NOTE:  If you do not provide an alias, the platform will auto generate the alias for you.

Example:
Suppose we have a requirement in which we need contact details like fullname, firstname, lastname and the account details like name and phone number that is related to contact.

Solution:
First, we will write a simple FetchXml query for contact in which we will select the attributes like fullname, firstname, lastname.

API Request:
https://dev-onepiece07.api.crm7.dynamics.com/api/data/v9.2/contacts?fetchXml=

Output:

2. As per the requirement that has been mentioned in the example, we will add the link- entity to get the account and its details like name and phone number that are related to contact.

2.a. We will use an inner link-type which will match the data of both the entity, and it will give the result.

API Request:

https://dev-onepiece07.api.crm7.dynamics.com/api/data/v9.2/contacts?fetchXml=

Output:

2.b. We will use an outer link-type which will give all the data of the first entity if there are no matching records.

API Request

https://dev-onepiece07.api.crm7.dynamics.com/api/data/v9.2/contacts?fetchXml=

Output:

NOTE: Each query can contain a maximum of 10 links

We have used the link-entity to fetch all contact details like fullname, firstname, lastname and the account details like name and phone number that is related to contact.

Comment

This is a Required Field

Recent Updates

Content styling
Case Study
20 Jul, 2024

Content styling

normal paragraph Bold paragraph Italic paragraph Bold italic paragraph Highlighted paragraph colored paragraph Highlighted & colored paragraph Heading 1 Heading 2…

READ MORE
Thum
Case Study
14 Jul, 2024

Revolutionizing Build Warranty's Operations with a Scalable and Automated Dynamics 365 Solution

Customer Overview Build Warranty (BW), a leading UK-based provider of warranty solutions for the construction industry, sought a strategic partner…

READ MORE
test
Blogs
16 Aug, 2023

Power BI - Test 1

asfwreg

READ MORE