Skip to content

Commit c795bb8

Browse files
authored
Live publish
2 parents 081e5dc + 9124a3c commit c795bb8

File tree

1 file changed

+94
-49
lines changed

1 file changed

+94
-49
lines changed

powerapps-docs/developer/common-data-service/webapi/retrieve-related-entities-query.md

Lines changed: 94 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Retrieve related entity records with a query (Microsoft Dataverse)| Microsoft Docs"
33
description: "Read how you can retrieve related entity records by expanding the navigation properties."
44
ms.custom: ""
5-
ms.date: 06/27/2020
5+
ms.date: 11/16/2020
66
ms.service: powerapps
77
ms.suite: ""
88
ms.tgt_pltfrm: ""
@@ -207,9 +207,11 @@ OData-Version: 4.0
207207

208208
## Retrieve related entities by expanding collection-valued navigation properties
209209

210-
If you expand on collection-valued navigation parameters to retrieve related entities for entity sets, an `@odata.nextLink` property will be returned for the related entities. You should use the value of the `@odata.nextLink` property with a new `GET` request to return the required data.
210+
If you expand on collection-valued navigation parameters to retrieve related entities for entity sets, only one level of depth is returned if there is data. Otherwise the collection will return an empty array.
211211

212-
The following example retrieves the tasks assigned to the top 2 account records.
212+
In either case an `@odata.nextLink` property will be returned for the related entities. If you want to retrieve the collection separately, you can use the value of the `@odata.nextLink` property with a new `GET` request to return the required data.
213+
214+
The following example retrieves the tasks assigned to the top 2 account records. One has related tasks, the other does not.
213215

214216
**Request**
215217

@@ -229,24 +231,46 @@ HTTP/1.1 200 OK
229231
Content-Type: application/json; odata.metadata=minimal
230232
OData-Version: 4.0
231233
232-
{
233-
"@odata.context":"[Organization URI]/api/data/v9.1/$metadata#accounts(name,Account_Tasks,Account_Tasks(subject,scheduledstart))",
234-
"value":[
235-
{
236-
"@odata.etag":"W/\"513475\"",
237-
"name":"Fourth Coffee (sample)",
238-
"accountid":"36dbf27c-8efb-e511-80d2-00155db07c77",
239-
"Account_Tasks":[],
240-
"[email protected]":"[Organization URI]/api/data/v9.1/accounts(36dbf27c-8efb-e511-80d2-00155db07c77)/Account_Tasks?$select%20=%20subject,%20scheduledstart"
241-
},
242-
{
243-
"@odata.etag":"W/\"513477\"",
244-
"name":"Litware, Inc. (sample)",
245-
"accountid":"38dbf27c-8efb-e511-80d2-00155db07c77",
246-
"Account_Tasks":[],
247-
"[email protected]":"[Organization URI]/api/data/v9.1/accounts(38dbf27c-8efb-e511-80d2-00155db07c77)/Account_Tasks?$select%20=%20subject,%20scheduledstart"
248-
}
249-
]
234+
{
235+
"@odata.context": "[Organization URI]/api/data/v9.1/$metadata#accounts(name,Account_Tasks(subject,scheduledstart))",
236+
"value": [
237+
{
238+
"@odata.etag": "W/\"37867294\"",
239+
"name": "Contoso, Ltd. (sample)",
240+
"accountid": "7a4814f9-b0b8-ea11-a812-000d3a122b89",
241+
"Account_Tasks": [
242+
{
243+
"@odata.etag": "W/\"28876919\"",
244+
"subject": "Task 1 for Contoso, Ltd.",
245+
"scheduledstart": null,
246+
"_regardingobjectid_value": "7a4814f9-b0b8-ea11-a812-000d3a122b89",
247+
"activityid": "7b4814f9-b0b8-ea11-a812-000d3a122b89"
248+
},
249+
{
250+
"@odata.etag": "W/\"28876923\"",
251+
"subject": "Task 2 for Contoso, Ltd.",
252+
"scheduledstart": null,
253+
"_regardingobjectid_value": "7a4814f9-b0b8-ea11-a812-000d3a122b89",
254+
"activityid": "7c4814f9-b0b8-ea11-a812-000d3a122b89"
255+
},
256+
{
257+
"@odata.etag": "W/\"28876927\"",
258+
"subject": "Task 3 for Contoso, Ltd.",
259+
"scheduledstart": null,
260+
"_regardingobjectid_value": "7a4814f9-b0b8-ea11-a812-000d3a122b89",
261+
"activityid": "7d4814f9-b0b8-ea11-a812-000d3a122b89"
262+
}
263+
],
264+
"[email protected]": "[Organization URI]/api/data/v9.1/accounts(7a4814f9-b0b8-ea11-a812-000d3a122b89)/Account_Tasks?$select=subject,scheduledstart"
265+
},
266+
{
267+
"@odata.etag": "W/\"37526208\"",
268+
"name": "Fourth Coffee",
269+
"accountid": "ccd685f9-cddd-ea11-a813-000d3a122b89",
270+
"Account_Tasks": [],
271+
"[email protected]": "[Organization URI]/api/data/v9.1/accounts(ccd685f9-cddd-ea11-a813-000d3a122b89)/Account_Tasks?$select=subject,scheduledstart"
272+
}
273+
]
250274
}
251275
252276
```
@@ -255,7 +279,7 @@ OData-Version: 4.0
255279

256280
## Retrieve related entities by expanding both single-valued and collection-valued navigation properties
257281

258-
The following example demonstrates how you can expand related entities for entity sets using both single- and collection-valued navigation properties. As explained earlier, expanding on collection-valued navigation properties to retrieve related entities for entity sets returns an `@odata.nextLink` property for the related entities. You should use the value of the `@odata.nextLink` property with a new `GET` request to return the required data.
282+
The following example demonstrates how you can expand related entities for entity sets using both single and collection-valued navigation properties. As explained earlier, expanding on collection-valued navigation properties to retrieve related entities for entity sets returns one level of depth and an `@odata.nextLink` property for the related entities.
259283

260284
In this example, we are retrieving the contact and tasks assigned to the top 2 accounts.
261285

@@ -278,33 +302,54 @@ HTTP/1.1 200 OK
278302
Content-Type: application/json; odata.metadata=minimal
279303
OData-Version: 4.0
280304
281-
{
282-
"@odata.context":"[Organization URI]/api/data/v9.1/$metadata#accounts(name,primarycontactid,Account_Tasks,primarycontactid(contactid,fullname),Account_Tasks(subject,scheduledstart))",
283-
"value":
284-
[
285-
{
286-
"@odata.etag":"W/\"550614\"",
287-
"name":"Fourth Coffee (sample)",
288-
"accountid":"5b9648c3-68f7-e511-80d3-00155db53318",
289-
"primarycontactid":{
290-
"contactid":"c19648c3-68f7-e511-80d3-00155db53318",
291-
"fullname":"Yvonne McKay (sample)"
292-
},
293-
"Account_Tasks":[],
294-
"[email protected]":"[Organization URI]/api/data/v9.1/accounts(5b9648c3-68f7-e511-80d3-00155db53318)/Account_Tasks?$select%20=%20subject,%20scheduledstart"
295-
},
296-
{
297-
"@odata.etag":"W/\"550615\"",
298-
"name":"Litware, Inc. (sample)",
299-
"accountid":"5d9648c3-68f7-e511-80d3-00155db53318",
300-
"primarycontactid":{
301-
"contactid":"c39648c3-68f7-e511-80d3-00155db53318",
302-
"fullname":"Susanna Stubberod (sample)"
303-
},
304-
"Account_Tasks":[],
305-
"[email protected]":"[Organization URI]/api/data/v9.1/accounts(5d9648c3-68f7-e511-80d3-00155db53318)/Account_Tasks?$select%20=%20subject,%20scheduledstart"
306-
}
307-
]
305+
{
306+
"@odata.context": "[Organization URI]/api/data/v9.1/$metadata#accounts(name,primarycontactid(contactid,fullname),Account_Tasks(subject,scheduledstart))",
307+
"value": [
308+
{
309+
"@odata.etag": "W/\"37867294\"",
310+
"name": "Contoso, Ltd. (sample)",
311+
"accountid": "7a4814f9-b0b8-ea11-a812-000d3a122b89",
312+
"primarycontactid": {
313+
"contactid": "7e4814f9-b0b8-ea11-a812-000d3a122b89",
314+
"fullname": "Yvonne McKay (sample)"
315+
},
316+
"Account_Tasks": [
317+
{
318+
"@odata.etag": "W/\"28876919\"",
319+
"subject": "Task 1 for Contoso, Ltd.",
320+
"scheduledstart": null,
321+
"_regardingobjectid_value": "7a4814f9-b0b8-ea11-a812-000d3a122b89",
322+
"activityid": "7b4814f9-b0b8-ea11-a812-000d3a122b89"
323+
},
324+
{
325+
"@odata.etag": "W/\"28876923\"",
326+
"subject": "Task 2 for Contoso, Ltd.",
327+
"scheduledstart": null,
328+
"_regardingobjectid_value": "7a4814f9-b0b8-ea11-a812-000d3a122b89",
329+
"activityid": "7c4814f9-b0b8-ea11-a812-000d3a122b89"
330+
},
331+
{
332+
"@odata.etag": "W/\"28876927\"",
333+
"subject": "Task 3 for Contoso, Ltd.",
334+
"scheduledstart": null,
335+
"_regardingobjectid_value": "7a4814f9-b0b8-ea11-a812-000d3a122b89",
336+
"activityid": "7d4814f9-b0b8-ea11-a812-000d3a122b89"
337+
}
338+
],
339+
"[email protected]": "[Organization URI]/api/data/v9.1/accounts(7a4814f9-b0b8-ea11-a812-000d3a122b89)/Account_Tasks?$select=subject,scheduledstart"
340+
},
341+
{
342+
"@odata.etag": "W/\"37526208\"",
343+
"name": "Fourth Coffee",
344+
"accountid": "ccd685f9-cddd-ea11-a813-000d3a122b89",
345+
"primarycontactid": {
346+
"contactid": "384d0f84-7de6-ea11-a817-000d3a122b89",
347+
"fullname": "Charlie Brown"
348+
},
349+
"Account_Tasks": [],
350+
"[email protected]": "[Organization URI]/api/data/v9.1/accounts(ccd685f9-cddd-ea11-a813-000d3a122b89)/Account_Tasks?$select=subject,scheduledstart"
351+
}
352+
]
308353
}
309354
```
310355

0 commit comments

Comments
 (0)