Hello Experts,
I am trying to retrieve a field from a custom entity. but I am getting the bad request error. I know this error occur if the query format is wrong. But I cant see any error in the query. Below is my complete code. I am calling this function in Case entity, onchange of a lookup field. Please suggest where is my mistake.
function GetProductPaltform(productId) {
//The OData end-point
var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
//Asynchronous AJAX function to Retrieve a CRM record using OData
$.ajax({
type: "GET", async: false, contentType: "application/json; charset=utf-8", datatype: "json", url: serverUrl + ODATA_ENDPOINT + "/new_productSet?$select=new_platform&$filter=new_productid eq guid'" + productId + "'", 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) { readRecord(data, textStatus, XmlHttpRequest) },
error: function (XmlHttpRequest, textStatus, errorThrown) {
alert("Error : " + textStatus +"\n "+ errorThrown)
}
});
}
function readRecord(data, textStatus, XmlHttpRequest) {
if (data.d.results.length > 0) { alert("Record read successfully!! - " + data.d.results.length); alert(data.d.results[0].new_platform); platformText = data.d.results[0].new_platform; } else { alert("No record found...."); } }
the schema name of the entity and attribute is in small case in our crm and the field I am retrieving is an optionset.
Best Regards,
Saroj