Hi All,
I am using below code to update an entity.
function UpdateOrphan(_formContext) {
var entityUpdate = {};
var newAcademicLevel = GetNewAcademicLevel(_formContext),
oldAcademicLevel = GetOldAcademicLevel(_formContext);
if (newAcademicLevel) {
entityUpdate[orphanFields.CurrentAcademicLevel] = newAcademicLevel;
} else if (oldAcademicLevel) {
entityUpdate[orphanFields.CurrentAcademicLevel] = null;
}
var orphan = GetOrphan(_formContext);
UpdateAndReturnUpdateStatus(entityUpdate, orphan[0].id, globalVariables.WebAPIVersion, entitys.Orphans);
}
function UpdateAndReturnUpdateStatus(entity, recordID, webAPIVersion, entitysPluralName) {
recordID = recordID.replace(/[{}]/g, "");
var req = new XMLHttpRequest();
req.open("PATCH", Xrm.Page.context.getClientUrl() + "/api/data/" + webAPIVersion + "/" + entitysPluralName + "(" + recordID + ")", false);//Sync
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204) {
globalVariables.UpdateStatus = true;
}
else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send(JSON.stringify(entity));
}
I am not able to set null with this code. I am receiving 204 in the return.
What is wrong in my code?
Thanks
Regards,
AW
*This post is locked for comments