Retrieve record in CRM 2016 using CRM web API with java script.
Hello CRM Developers,
Here is my new post, In this post I am going to to tell how to delete record in dynamics CRM 2016 using CRM web API.
In new CRM 2016 release there is a new way introduced for operation like create, update, delete,retrieve, multiple retrieve etc, using web API. Web API has been introduced so that communication between CRM and and other platform application can be done easily. New CRM web API is fully supports JSON format.
In new CRM 2016 release there is a new way introduced for operation like create, update, delete,retrieve, multiple retrieve etc, using web API. Web API has been introduced so that communication between CRM and and other platform application can be done easily. New CRM web API is fully supports JSON format.
Below is the sample java script code for retrieving record in CRM using java script.
function deleteRecord() {
var clientURL = Xrm.Page.context.getClientUrl();
var req = new XMLHttpRequest()
var query = "/api/data/v8.0/accounts(00000000-0000-0000-0000-000000000000)";
req.open("Delete", encodeURI(clientURL + query), true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json;charset=utf-8");
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.onreadystatechange = function () {
if (this.readyState == 4) {
req.onreadystatechange = null;
if (this.status == 204) {
alert("Success");
}
else {
var error = JSON.parse(this.response).error;
alert("Error deleting Account – " + error.message);
}
}
};
req.send(null);
}
For further help you can leave a comment.
Enjoy the great technology Dynamics CRM. Good Luck .....!!!!
Thanks