Hi Folks,
To Delete a record in CRM, we require JQuery min 1.4 & JSON2 script file which we can get from SDK from this specific path
SampleCode\JS\RESTEndpoint\JavaScriptRESTDataOperations\JavaScriptRESTDataOperations\Scripts
Now add the following code to your webresource,
Also add JSon.js and Jquery1.4min.js to the Library
--------------------------->
function update()
{
var lookupObject = Xrm.Page.getAttribute("new_lookup").getValue(); //Getting id throug lookup
var id = lookupObject[0].id;
var set="new_entity5Set";
updateRecord(id, set);
}
function updateRecord(id, odataSetName) {
var serverUrl = Xrm.Page.context.getServerUrl();
var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: serverUrl + ODATA_ENDPOINT + "/" + odataSetName + "(guid'"+id+"')",
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json");
XMLHttpRequest.setRequestHeader("X-HTTP-Method", "DELETE");
},
success: function (data, textStatus, XmlHttpRequest) {
alert("Deleted successfully");
},
error: function (XmlHttpRequest, textStatus, errorThrown) {
alert("Error while deletion " + errorThrown);
}
});
}
--------------------------->
To Delete a record in CRM, we require JQuery min 1.4 & JSON2 script file which we can get from SDK from this specific path
SampleCode\JS\RESTEndpoint\JavaScriptRESTDataOperations\JavaScriptRESTDataOperations\Scripts
Now add the following code to your webresource,
Also add JSon.js and Jquery1.4min.js to the Library
--------------------------->
function update()
{
var lookupObject = Xrm.Page.getAttribute("new_lookup").getValue(); //Getting id throug lookup
var id = lookupObject[0].id;
var set="new_entity5Set";
updateRecord(id, set);
}
function updateRecord(id, odataSetName) {
var serverUrl = Xrm.Page.context.getServerUrl();
var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: serverUrl + ODATA_ENDPOINT + "/" + odataSetName + "(guid'"+id+"')",
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json");
XMLHttpRequest.setRequestHeader("X-HTTP-Method", "DELETE");
},
success: function (data, textStatus, XmlHttpRequest) {
alert("Deleted successfully");
},
error: function (XmlHttpRequest, textStatus, errorThrown) {
alert("Error while deletion " + errorThrown);
}
});
}
--------------------------->
No comments:
Post a Comment