Skip to content

Commit 2b6a5f0

Browse files
upd: readme
1 parent 8ba10f3 commit 2b6a5f0

File tree

1 file changed

+63
-2
lines changed

1 file changed

+63
-2
lines changed

README.md

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Any suggestions are welcome!
3838
* [Execute Web API functions](#execute-web-api-functions)
3939
* [Execute Web API actions](#execute-web-api-actions)
4040
* [Formatted Values and Lookup Properties](#formatted-values-and-lookup-properties)
41+
* [Alternate Key](#alternate-key)
4142
* [JavaScript Promises](#javascript-promises)
4243
* [JavaScript Callbacks](#javascript-callbacks)
4344

@@ -181,11 +182,11 @@ Property Name | Type | Operation(s) Supported | Description
181182
async | Boolean | All | **Important! XHR requests only!** Indicates whether the requests should be made synchronously or asynchronously. Default value is `true` (asynchronously).
182183
collection | String | All | The name of the Entity Collection, for example, for `account` use `accounts`, `opportunity` - `opportunities` and etc.
183184
count | Boolean | `retrieveMultipleRequest`, `retrieveAllRequest` | Boolean that sets the $count system query option with a value of true to include a count of entities that match the filter criteria up to 5000 (per page). Do not use $top with $count!
184-
duplicateDetection | Boolean | `createRequest`, `updateRequest`, `upsertRequest` | `v.1.3.4+` ** Web API v9+ only!** Boolean that enables duplicate detection. [More info](https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/webapi/update-delete-entities-using-web-api#check-for-duplicate-records)
185+
duplicateDetection | Boolean | `createRequest`, `updateRequest`, `upsertRequest` | `v.1.3.4+` **Web API v9+ only!** Boolean that enables duplicate detection. [More info](https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/webapi/update-delete-entities-using-web-api#check-for-duplicate-records)
185186
entity | Object | `updateRequest`, `upsertRequest` | A JavaScript object with properties corresponding to the logical name of entity attributes (exceptions are lookups and single-valued navigation properties).
186187
expand | Array | `retrieveRequest`, `updateRequest`, `upsertRequest` | An array of Expand Objects (described below the table) representing the $expand OData System Query Option value to control which related records are also returned.
187188
filter | String | `retrieveRequest`, `retrieveMultipleRequest`, `retrieveAllRequest` | Use the $filter system query option to set criteria for which entities will be returned.
188-
id | String | `retrieveRequest`, `updateRequest`, `upsertRequest`, `deleteRequest` | `deprecated in v.1.3.4` Use `key` field, instead of `id`. A String representing the GUID value for the record.
189+
id | String | `retrieveRequest`, `updateRequest`, `upsertRequest`, `deleteRequest` | `deprecated in v.1.3.4` Use `key` field, instead of `id`. A String representing the Primary Key (GUID) of the record.
189190
ifmatch | String | `retrieveRequest`, `updateRequest`, `upsertRequest`, `deleteRequest` | Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests. [More info](https://msdn.microsoft.com/en-us/library/mt607711.aspx).
190191
ifnonematch | String | `retrieveRequest`, `upsertRequest` | Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. [More info](https://msdn.microsoft.com/en-us/library/mt607711.aspx).
191192
impersonate | String | All | A String representing the GUID value for the Dynamics 365 system user id. Impersonates the user.
@@ -902,6 +903,64 @@ OData Annotation | Property Suffix
902903
`@Microsoft.Dynamics.CRM.lookuplogicalname` | `_LogicalName`
903904
`@Microsoft.Dynamics.CRM.associatednavigationproperty` | `_NavigationProperty`
904905

906+
## Alternate Key
907+
Starting from version 1.3.4, you can use alternate keys to Update, Upsert, Retrieve and Delete records. [More Info] (https://msdn.microsoft.com/en-us/library/mt607871.aspx#Retrieve%20using%20an%20alternate%20key)
908+
909+
### Basic usage
910+
911+
```js
912+
var alternateKey = "alternateKey='keyValue'";
913+
//or "alternateKey='keyValue',anotherKey='keyValue2'""
914+
915+
//perform a retrieve operaion
916+
dynamicsWebApi.retrieve(alternateKey, "leads", ["fullname", "subject"]).then(function (record) {
917+
//do something with a record here
918+
})
919+
.catch(function (error) {
920+
//catch an error
921+
});
922+
```
923+
924+
### Advanced using Request Object
925+
926+
Please use `key` instead of `id` for all requests that you make using DynamicsWebApi starting from `v.1.3.4`.
927+
928+
Please note, that `id` field is not removed from the libarary, so all your existing scripts will work without any issue.
929+
930+
```js
931+
var request = {
932+
key: "alternateKey='keyValue'",
933+
//key can be used as a primary key (id)
934+
//key: '00000000-0000-0000-0000-000000000001',
935+
collection: 'leads',
936+
select: ['fullname', 'subject']
937+
};
938+
939+
dynamicsWebApi.retrieveRequest(request).then(function (record) {
940+
//do something with a record
941+
})
942+
.catch(function (error) {
943+
//if the record has not been found the error will be thrown
944+
});
945+
```
946+
947+
`key` can be used as a primary key (id):
948+
949+
```js
950+
var request = {
951+
key: '00000000-0000-0000-0000-000000000001',
952+
collection: 'leads',
953+
select: ['fullname', 'subject']
954+
};
955+
956+
dynamicsWebApi.retrieveRequest(request).then(function (record) {
957+
//do something with a record
958+
})
959+
.catch(function (error) {
960+
//if the record has not been found the error will be thrown
961+
});
962+
```
963+
905964
### In Progress
906965

907966
- [X] Overloaded functions with rich request options for all Web API operations.
@@ -911,6 +970,8 @@ Feature is very convenient for big Fetch XMLs. `Implemented in v.1.2.8`
911970
- [X] "Formatted" values in responses. For instance: Web API splits information about lookup fields into separate properties,
912971
the config option "formatted" will enable developers to retrieve all information about such fields in a single requests and access it through DynamicsWebApi custom response objects.
913972
- [X] Simplified names for "Formatted" properties. `Implemented in v.1.3.0`
973+
- [X] RUD operations using Alternate Keys. `Implemented in v.1.3.4`
974+
- [X] Duplicate Detection for Web API v.9. `Implemented in v.1.3.4`
914975
- [ ] Batch requests.
915976
- [ ] Web API Authentication for On-Premise instances.
916977
- [ ] Intellisense for request objects.

0 commit comments

Comments
 (0)