Skip to content

Commit d87f2ea

Browse files
committed
address review comments
1 parent 0e92569 commit d87f2ea

File tree

1 file changed

+25
-39
lines changed

1 file changed

+25
-39
lines changed

powerapps-docs/developer/model-driven-apps/clientapi/reference/Xrm-WebApi/retrieveMultipleRecords.md

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -253,55 +253,41 @@ The above piece of code returns a result with a schema like:
253253
```
254254

255255
#### For mobile offline scenario
256-
When doing an **$expand** operation while working offline, the structure of the result object is different from the online scenario and a different approach is needed to get to the linked data in this case. The following example demonstrates this:
257-
258-
```JavaScript
259-
Xrm.WebApi.offline.retrieveMultipleRecords("account", "?$select=name&$top=3&$expand=primarycontactid($select=contactid,fullname)", 3).then(
260-
function success(result) {
261-
for (var i = 0; i < result.entities.length; i++) {
262-
console.log(result.entities[i]);
263-
}
264-
// perform additional operations on retrieved records
265-
},
266-
function (error) {
267-
console.log(error.message);
268-
// handle error conditions
269-
}
270-
);
271-
```
272-
273-
The above piece of code returns a result with a schema like:
274-
```JSON
275-
{
276-
"entities": [
277-
{
278-
"accountid": "119edfac-19c6-ea11-a81a-000d3af5e732",
279-
"name": "Test Account",
280-
281-
"API": "{Xrm.Mobile.offline}.{retrieveRecord}",
282-
"id": "119edfac-19c6-ea11-a81a-000d3af5e732",
283-
"entityType": "account",
284-
"options": "?$select=accountid&$expand=primarycontactid($select=contactid,fullname)&$getOnlyRelatedEntity=true"
285-
},
286-
"primarycontactid": {}
287-
}
288-
]
289-
}
290-
```
291-
292-
Notice the empty `primarycontactid` property but an additional `[email protected]` annotation that lets us know how to get to the linked data that we need. Use the `id`, `entityType`, and `options` parameter of that property to construct one or more additional `Xrm.WebApi.offline.retrieveRecord` request(s). The following piece of code provides a complete example of how to do this:
256+
**$expand** for the mobile offline scenario is different from the online scenario and is a multi-part process. An offline **\$expand** operation returns a `@odata.nextLink` annotation containing information on how to get to the related record's information. We use the `id`, `entityType`, and `options` parameter of that annotation to construct one or more additional `Xrm.WebApi.offline.retrieveRecord` request(s). The following piece of code provides a complete example of how to do this:
293257

294258
```JavaScript
295259
Xrm.WebApi.offline.retrieveMultipleRecords("account", "?$select=name&$top=3&$expand=primarycontactid($select=contactid,fullname)").then(function(resultSet) {
260+
/**
261+
* resultSet has a structure like:
262+
* {
263+
* "entities": [
264+
* {
265+
* "accountid": "119edfac-19c6-ea11-a81a-000d3af5e732",
266+
* "name": "Test Account",
267+
268+
* "API": "{Xrm.Mobile.offline}.{retrieveRecord}",
269+
* "id": "119edfac-19c6-ea11-a81a-000d3af5e732",
270+
* "entityType": "account",
271+
* "options": "?$select=accountid&$expand=primarycontactid($select=contactid,fullname)&$getOnlyRelatedEntity=true"
272+
* },
273+
* "primarycontactid": {}
274+
* }
275+
* ]
276+
* }
277+
*
278+
* Notice the empty `primarycontactid` property but an additional `[email protected]`
279+
* annotation that lets us know how to get to the linked data that we need.
280+
**/
281+
296282
var promises = resultSet.entities.map(function(outerItem) {
297283
// We do a retrieveRecord() for every item in the result set of retrieveMultipleRecords() and then
298-
// combine its results into the retrieveMultipleRecords() result set itself.
284+
// combine the results into the retrieveMultipleRecords() result set itself.
299285
return Xrm.WebApi.offline.retrieveRecord(
300286
outerItem["[email protected]"].entityType,
301287
outerItem["[email protected]"].id,
302288
outerItem["[email protected]"].options
303289
).then(function(innerResult) {
304-
if(innerResult.value.length === 0) {
290+
if (innerResult.value.length === 0) {
305291
return outerItem;
306292
}
307293
outerItem.primarycontactid = innerResult.value[0];

0 commit comments

Comments
 (0)