Hi professionals
var context = Xrm.Page.context;
var serverUrl = context.getServerUrl();
var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
var CRMObject = new Object();
/////////////////////////////////////////////////////////////
// Specify the ODATA entity collection
var ODATA_EntityCollection = "/CustomEntity";
/////////////////////////////////////////////////////////////
// Define attribute values for the CRM object you want created
CRMObject.phk_name = "TEST";
CRMObject.phk_primarycontactid = "123";
CRMObject.phk_customeraccount = Lookup;
//Parse the entity object into JSON
var jsonEntity = window.JSON.stringify(CRMObject);
//Asynchronous AJAX function to Create a CRM record using OData
$.ajax({ type: "POST",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: serverUrl + ODATA_ENDPOINT + ODATA_EntityCollection,
data: jsonEntity,
beforeSend: function (XMLHttpRequest) {
//Specifying this header ensures that the results will be returned as JSON.
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
success: function (data, textStatus, XmlHttpRequest) {
alert("success");
var NewCRMRecordCreated = data["d"];
alert("CRM GUID created: " + NewCRMRecordCreated.AccountId);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("failure");
}
});
My Entity name is "phk_projects"
I want to use this in above code in
var ODATA_EntityCollection = "/?"
How i will use this for entity record creation using OData Rest 2011 Javascript?