Hi,
I am trying to update the status of a case to "Resolved" using JavaScript web resources but the case status is not getting updated. If I am using the same code in REST builder and it is changing to Resolved. Can someone suggest the changes or point out the error in my code ???
<script>
function getdata()
{
var CId = localStorage.getItem("record_id");
var CIDFormatted = CId.toString().slice(1, -1);
alert(CId);
var entity = {};
entity.statuscode.Value=5;
var req = new XMLHttpRequest();
req.open("PATCH", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/incidents(" + CIDFormatted + ")", false);
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) {
//Success - No Return Data - Do Something
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send(JSON.stringify(entity));
}
</script>
Thanks,
Abhilash