22:12 -
2 comments
Delete a Record in CRM using OData Query | MS CRM
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 web resource,
Also add JSon.js and Jquery1.4min.js to the Library
SampleCode\JS\RESTEndpoint\JavaScriptRESTDataOperations\JavaScriptRESTDataOperations\Scripts
Now add the following code to your web resource,
Also add JSon.js and Jquery1.4min.js to the Library
---------->
function delete()
{
var lookupObject = Xrm.Page.getAttribute("new_lookup").getValue(); //getting the id through lookup
var id = lookupObject[0].id;
var set="your entity schema nameSet"
deletelog(id,set);
}
function deletelog(id,odata)
{
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);
}
});
}
2 comments:
hi
Thanks for posting to delete operation in java script using OData Query | MS CRM. but i am getting "INTERNAL SERVER ERROR" can u plz suggest me who can i slove this issue.thank you
C++ Programming Examples samples to students
Post a Comment