使用Odata查询我正在获取CRM字段。但是statuscode
的类型为OptionSet
,你如何得到statuscode
。我尝试了下面的代码,它无法获得0或未定义。你有什么参考赞赏的吗?
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: odata_point + "(guid'" + x + "')",
beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Accept", "application/json"); },
success: function (data, textStatus, XmlHttpRequest) {
RetrieveEntityData(data.d);
alert(data.d.Name);
alert(data.d[0].StatusCode.Value); //here i'm getting Unable to get 0 or undefined.
}
答案 0 :(得分:2)
var retrievedLeadState = data.d.results[0].StateCode;
// StateCode is an OptionSet so we must use eval-function
var stateCode = eval(retrievedLeadState.Value);
alert(stateCode);
参考:CRM 2011: Retrieve StateCode (Status) using oData (REST) Service Endpoint