I am Using CRM 2011 IFD
I am Creating Record Using OData Jquery JavaScript
I required newly created record id that I have to use to open that created record.
function CreateBikePlan(account,oppProduct,BikeShop) {
var serverUrl = Xrm.Page.context.getServerUrl().toString();
var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
var ODATA_EntityCollection = "/new_bikeplanSet";
var objBikePlan = new Object();
// set the name of BikePlan
if(oppProduct[0].ProductId.Id!=null)
{
objBikePlan.new_name =oppProduct[0].ProductId.Name+"-"+BikeShop[0].new_BikeShop.Name;
objBikePlan.new_BikeNameProduct={Id:oppProduct[0].ProductId.Id, Name:oppProduct[0].ProductId.Name, LogicalName:oppProduct[0].ProductId.LogicalName};
}
// Parse the entity object into JSON
var jsonEntity = window.JSON.stringify(objBikePlan);
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: serverUrl + ODATA_ENDPOINT + ODATA_EntityCollection,
data: jsonEntity,
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
success: function (response) {
if (response != null && response.d != null) {
var NewRecordCreated = data;
alert(NewRecordCreated.new_bikeplanId.tostring());
}
},
error: function (xmlHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus + "; ErrorThrown: " + errorThrown);
}
});
}
Muhammad Sohail