Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Updating a record using ODATA end point?

$
0
0

Hi i'm trying to updating a existing record by passing guid variable from the web page using Odata endpoint. If i hard coded the value its working fine, but if i make it dynamic  by passing variable , its not updating a record. i thought its taking double quotes along with GUID, i'm not sure . Please help me if anybody knows the solution.

Thanks in advance.

function updateExistingXmlRecord(fetch, name,guid) {
var entity = {};
entity.new_fetchxml = fetch;
entity.new_name = name;
var newguid=guid.replace(/\"/g,'');

var req = new XMLHttpRequest();
req.open("PATCH", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/new_*******(newguid)", true);
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) {
var results = JSON.parse(this.response);
alert(results);
//Success - No Return Data - Do Something
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send(JSON.stringify(entity));
}


Viewing all articles
Browse latest Browse all 46379


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>