You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Batch requests bundle multiple operations into a single one and have the following advantages:
1608
+
1609
+
* Reduces a number of requests sent to the Web API server. `Each user is allowed up to 60,000 API requests, per organization instance, within five minute sliding interval.`[More Info](https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/api-limits)
1610
+
* Provides a way to run multiple operations in a single transaction. If any operation that changes data (within a single changeset) fails all completed ones will be rolled back.
1611
+
* All operations within a batch request run consequently (FIFO).
1612
+
1613
+
Batch requests are not simple to compose and DynamicsWebApi provides an easy way to execute such operations:
1614
+
1615
+
```js
1616
+
1617
+
//when you want to start a batch operation call the following function:
1618
+
//it is important to call it, otherwise all operations below will be executed right away.
1619
+
dynamicsWebApi.startBatch();
1620
+
1621
+
//call necessary operations just like you would normally do.
1622
+
//these calls will be converted into a single batch request
//'responses' is an array of responses of each individual request
1631
+
//they have the same sequence as the calls between startBatch() and executeBatch()
1632
+
//in this case responses.length is 3
1633
+
1634
+
//dynamicsWebApi.retrieveMultiple response:
1635
+
var accounts = responses[0];
1636
+
//dynamicsWebApi.update response
1637
+
var isUpdated = responses[1]; //should be 'true'
1638
+
//dynamicsWebApi.retrieveMultiple response:
1639
+
var contacts = responses[2]; //will contain an updated contact
1640
+
1641
+
}).catch(function (error) {
1642
+
//catch error here
1643
+
});
1644
+
1645
+
```
1646
+
1647
+
**Important!** Developers who use DynamicsWebApi with callbacks do not need to pass `successCallback` and `errorCallback` in an individual operation when `startBatch()` is called,
1648
+
just pass `null` if you need to add additional parameters in the request.
1649
+
1650
+
Currently, there are some limitations in DynamicsWebApi Batch Operations:
1651
+
1652
+
*`Content-ID` header cannot be used to reference the Uri of any entity created in a single operation. **This is an upcoming feature**.
1653
+
* Operations that use pagination to recursively retrieve all records cannot be used in a batch operation. These operations include: `retrieveAll`, `retrieveAllRequest`, `countAll`, `fetchAll`, `executeFetchXmlAll`.
1654
+
You will get an error saying that the operation is incompatible in a 'batch mode'.
1655
+
1656
+
There are also some Web API limitations for batch operations:
1657
+
1658
+
* Batch requests can contain up to 100 individual requests and cannot contain other batch requests.
1659
+
* The odata.continue-on-error preference is not supported by the web API. Any error that occurs in the batch will stop the processing of the remainder of the batch.
1660
+
1661
+
You can find an official documentation that covers Web API batch requests here: [Execute batch operations using the Web API](https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/webapi/execute-batch-operations-using-web-api)
1662
+
1602
1663
## Formatted Values and Lookup Properties
1603
1664
1604
1665
Starting from version 1.3.0 it became easier to access formatted values for properties and lookup data in response objects.
@@ -1768,7 +1829,8 @@ the config option "formatted" will enable developers to retrieve all information
1768
1829
-[X] Ability to use entity names instead of collection names. `Implemented in v.1.4.0`
1769
1830
-[X] Entity and Attribute Metadata helpers. `Implemented in v.1.4.3`
1770
1831
-[X] Entity Relationships and Global Option Sets helpers. `Implemented in v.1.4.6`
1771
-
-[ ] Batch requests.
1832
+
-[X] Batch requests.
1833
+
-[ ] Implement `Content-ID` header to reference a created entity in batch operation.
0 commit comments