Delete a single property value:
To delete the value of a single property use a DELETE request with the
property name appended to the Uri of the entity.
The following example deletes the value of the fax property of an account entity.
The following example deletes the value of the fax property of an account entity.
function UpdatAccountSingleValueUsingDELETE() { debugger; var clientURL = Xrm.Page.context.getClientUrl(); var AccountId = "B3A2B300-A8AF-E511-80DD-6C3BE5A878BC"; //Single Property value which you want to delete var Property ="fax"; UpdatAccountSingleValue(AccountId,clientURL,Property); } function UpdatAccountSingleValue(AccountId,clientURL,Property) { var req = new XMLHttpRequest(); req.open('DELETE', clientURL + "/api/data/v8.0/accounts(" + AccountId + ")/"+Property, true); req.setRequestHeader("Content-type","application/json"); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.onreadystatechange = function () { if (this.readyState == 4 /* complete */) { req.onreadystatechange = null; if (this.status == 204) { console.log("Updated account with ID: "+ AccountId) } else { var error = JSON.parse(this.response).error; console.log(error.message); } } }; req.send(); }
It's a wonderful post and very helpful, thanks for all this information.
ReplyDeleteMicrosoft Dynamics AX Online Training