How to Delete Records on Dynamics 365

How to Delete Records on Dynamics 365 CRUD in Dynamics 365

On this Section we will see the How to Delete the records on Dynamics 365 instance.

There is a "deleteRecord" method used for deleting records from dynamics 365 entity.

1. To delete records Xrm.WebApi.deleteRecord. the required parameter is given below:
- Entity Logical Name
- Entity Guid



Syntax : Xrm.WebApi.deleteRecord("Entiy", "Guid")


Example : Retrive Record
//Note :- Initialized the XRM boject first
var Xrm = parent.Xrm;
//Step 1- Create a Javascript fumction
function deleteRecord() {
try {
Xrm.WebApi.deleteRecord("contact","xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx")
.then(function (result) {
Xrm.Utility.alertDialog("Record deleted successfully.");
})
.fail(function (error) {
Xrm.Utility.alertDialog(e.message);
});
} catch (e) {
Xrm.Utility.alertDialog(e.message);
}
}

Comments