Last active
September 16, 2019 02:24
-
-
Save ryanmichaeljames/a9cba1986e839967f8ff2ffc1f1f97a9 to your computer and use it in GitHub Desktop.
Delete operation with Xrm.WebApi.online.execute
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 delete a record | |
* @param {Object} entityReference - The entity reference. | |
*/ | |
Sdk.DeleteRequest = function (entityReference) { | |
this.entityReference = entityReference; | |
this.getMetadata = function () { | |
return { | |
boundParameter: null, | |
parameterTypes: {}, | |
operationType: 2, | |
operationName: "Delete", | |
}; | |
}; | |
}; | |
// Construct a request object from the metadata | |
var request = new Sdk.DeleteRequest({ entityType: "new_entity", id: "00000000-0000-0000-0000-000000000000" }); | |
// Use the request object to execute the function | |
Xrm.WebApi.online.execute(request).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