Skip to content

Instantly share code, notes, and snippets.

@ryanmichaeljames
Last active September 16, 2019 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanmichaeljames/6866f8a2c077306b487962757edf74d1 to your computer and use it in GitHub Desktop.
Save ryanmichaeljames/6866f8a2c077306b487962757edf74d1 to your computer and use it in GitHub Desktop.
Update operation with Xrm.WebApi.online.executeMultiple
var Sdk = window.Sdk || {};
/**
* Request to update a record
* @param {string} entityTypeName - The entity type name.
* @param {string} id - The record ID.
* @param {Object} payload - The entity payload.
*/
Sdk.UpdateRequest = function (entityTypeName, id, payload) {
this.etn = entityTypeName;
this.id = id;
this.payload = payload;
this.getMetadata = function () {
return {
boundParameter: null,
parameterTypes: {},
operationType: 2,
operationName: "Update",
};
};
};
// Construct a request object array from the metadata
var requests = [
new Sdk.UpdateRequest("new_entity", "00000000-0000-0000-0000-000000000000", { "new_name": "Foo" }),
new Sdk.UpdateRequest("new_entity", "00000000-0000-0000-0000-000000000000", { "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