Last active
September 16, 2019 20:34
-
-
Save ryanmichaeljames/4c9f87dc4296cea817048df5a1aa62a4 to your computer and use it in GitHub Desktop.
Create operation with Xrm.WebApi.online.executeMultiple
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Sdk = window.Sdk || {}; | |
/** | |
* Request to create a record | |
* @param {string} entityTypeName - The entity type name. | |
* @param {Object} payload - The entity payload. | |
*/ | |
Sdk.CreateRequest = function (entityTypeName, payload) { | |
this.etn = entityTypeName; | |
this.payload = payload; | |
this.getMetadata = function () { | |
return { | |
boundParameter: null, | |
parameterTypes: {}, | |
operationType: 2, | |
operationName: "Create", | |
}; | |
}; | |
}; | |
// Construct a request object array from the metadata | |
var requests = [ | |
new Sdk.CreateRequest("new_entity", { "new_name": "Foo" }), | |
new Sdk.CreateRequest("new_entity", { "new_name": "Bar" }) | |
]; | |
// Use the request object array to execute the function | |
Xrm.WebApi.online.executeMultiple(requests).then( | |
(result) => { | |
if (result.ok) { | |
console.log(`${result.status} ${result.statusText}`); | |
} | |
}, | |
(error) => { | |
console.log(error.message); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment