Detele Records Using WEBAPI
=================================================================
function DeteleRecord() {
var lookup = Xrm.Page.data.entity.getId();
var lookupID = lookup.replace('{', '').replace('}', '');
var req = new XMLHttpRequest();
req.open("DELETE", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/new_testcrms(" + lookupID + ")", 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 || this.status === 1223) {
alert("deleted record successfully..");
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
}
No comments:
Post a Comment