Xrm.WebApi.online.executeMultiple (Client API reference)
Execute a collection of action, function, or CRUD operations.
Note
This method is supported only for the online mode (Xrm.WebApi.online).
If you want to execute multiple requests in a transaction, you must pass in a change set as a parameter to this method. Change sets represent a collection of operations that are executed in a transaction. You can also pass in individual requests and change sets together as parameters to this method.
Note
- You cannot include read operations (retrieve, retrieve multiple, and Web API functions) as part of a change set; this is as per the OData v4 specifications.
- Requests can contain up to 1000 individual requests and cannot contain other batches. More information: Execute batch operations.
Syntax
Execute multiple requests:
var requests = [req1, req2, req3];
Xrm.WebApi.online.executeMultiple(requests).then(successCallback, errorCallback);
Execute multiple requests in a transaction:
In this case, req1
, req2
, and req3
are executed in a transaction.
var changeSet = [req1, req2, req3];
var requests = [changeSet];
Xrm.WebApi.online.executeMultiple(requests).then(successCallback, errorCallback);
Execute a mix of individual requests and multiple requests in a transaction:
In this case, req1
, req2
, and req3
are executed in transaction, but req4
and req5
are executed individually.
var changeSet = [req1, req2, req3];
var requests = [req4, req5, changeset];
Xrm.WebApi.online.executeMultiple(requests).then(successCallback, errorCallback);
Parameters
Name | Type | Required | Description |
---|---|---|---|
requests |
Array of objects | Yes | An array of one of the following types: Objects where each object is an action, function, or CRUD request that you want to execute against the Web API endpoint. Each object exposes a getMetadata method that lets you define the metadata for the action, function, or CRUD request you want to execute. The execute method accepts this type of parameter. Change set (an array of objects), where each object in the change set is as defined above. In this case, all the request objects specified in the change set are executed in a transaction. See request examples in the Syntax section for more information. |
successCallback |
Function | No | A function to call when operation is executed successfully. An array of response objects is passed to the function. See Return Value |
errorCallback |
Function | No | A function to call when the operation fails. |
Return Value
On success, returns a promise containing an array of objects to the successCallback
. The objects have these properties:
Name | Type | Required | Description |
---|---|---|---|
json |
Promise | No | Response body in JSON format. |
text |
Promise | No | Response body in plaintext format. |
headers |
Object | Yes | Response headers. |
ok |
Boolean | Yes | Indicates whether the request was successful. |
status |
Number | Yes | Numeric value in the response status code. For example: 200 |
statusText |
String | Yes | Description of the response status code. For example: OK |
type |
String | Yes | Response type. Values are: the empty string (default), arraybuffer , blob , document , json , and text . |
url |
String | Yes | Request URL of the action, function, or CRUD request that was sent to the Web API endpoint. |