Skip to content

Commit 1e4b7a7

Browse files
authored
Merge pull request #2291 from MicrosoftDocs/ian-legler-retrieveMultiple-lookup-take2
Update retrieveMultipleRecords for lookup, take 2
2 parents 5c8b555 + da01506 commit 1e4b7a7

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,50 @@ Xrm.WebApi.retrieveMultipleRecords("account", "?$select=name&$top=3").then(
105105
);
106106
```
107107

108+
### Retrieve or filter by lookup properties
109+
For most single-valued navigation properties you will find a computed, read-only property that uses the following naming convention: `_<name>_value` where the `<name>` is the name of the single-valued navigation property. For filtering purposes, the specific value of the single-valued navigation property can also be used. However, for mobile clients in offline mode, these syntax options are not supported, and the single-value navigation property name should be used for both retrieving and filtering. Also, the comparison of navigation properties to null is not supported in offline mode.
108110

111+
More information: [Lookup properties](../../../../common-data-service/webapi/web-api-types-operations.md#bkmk_lookupProperties)
112+
113+
Here are code examples for both the scenarios:
114+
115+
#### For online scenario (connected to server)
116+
117+
This example queries the accounts entity set and uses the `$select` and `$filter` system query options to return the name and primarycontactid property for accounts that have a particular primary contact:
118+
119+
```JavaScript
120+
Xrm.WebApi.retrieveMultipleRecords("account", "?$select=name,_primarycontactid_value&$filter=primarycontactid/contactid eq a0dbf27c-8efb-e511-80d2-00155db07c77").then(
121+
function success(result) {
122+
for (var i = 0; i < result.entities.length; i++) {
123+
console.log(result.entities[i]);
124+
}
125+
// perform additional operations on retrieved records
126+
},
127+
function (error) {
128+
console.log(error.message);
129+
// handle error conditions
130+
}
131+
);
132+
```
133+
134+
#### For mobile offine scenario
135+
136+
This example queries the accounts entity set and uses the `$select` and `$filter` system query options to return the name and primarycontactid property for accounts that have a particular primary contact when working in the offline mode:
137+
138+
```JavaScript
139+
Xrm.WebApi.retrieveMultipleRecords("account", "?$select=name,primarycontactid&$filter=primarycontactid eq a0dbf27c-8efb-e511-80d2-00155db07c77").then(
140+
function success(result) {
141+
for (var i = 0; i < result.entities.length; i++) {
142+
console.log(result.entities[i]);
143+
}
144+
// perform additional operations on retrieved records
145+
},
146+
function (error) {
147+
console.log(error.message);
148+
// handle error conditions
149+
}
150+
);
151+
```
109152
### Specify the number of entities to return in a page
110153

111154
The following example demonstrates the use of the `maxPageSize` parameter to specify the number of records (3) to be displayed in a page.

0 commit comments

Comments
 (0)