Hi ,
i was trying to create multiple records by using below code example but i am getting error in payload construction.
1)is it possible to create multiple records with xrm.webApi.Execute in single go like below
2)if not wny sample example for doing so with any other approach
var Sdk = window.Sdk || {};
/**
* Request to execute a create operation
*/
Sdk.CreateRequest = function(entityName, payload) {
this.etn = entityName;
this.payload = payload;
};
// NOTE: The getMetadata property should be attached to the function prototype instead of the
// function object itself.
Sdk.CreateRequest.prototype.getMetadata = function () {
return {
boundParameter: null,
parameterTypes: {},
operationType: 2, // This is a CRUD operation. Use '0' for actions and '1' for functions
operationName: "Create",
};
};
// Construct a request object from the metadata
var payload = [{
name: "Fabrikam Inc."
},{name:"test"}];
var createRequest = new Sdk.CreateRequest("account", payload);
// Use the request object to execute the function
Xrm.WebApi.online.execute(createRequest)
.then(function (response) {
if (response.ok) {
console.log("Status: %s %s", result.status, result.statusText);
// The Create request does not return any response body content. So we
// need not access the response.json() property.
// Perform other operations as required.
}
})
.catch(function(error) {
console.log(error.message);
// handle error conditions
});