crm2011:使用oData(REST)服务端点检索StateCode(Status)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了crm2011:使用oData(REST)服务端点检索StateCode(Status)相关的知识,希望对你有一定的参考价值。
How to retrieve entity StateCode (Status) in javascript by accessing CRM oDATA (REST) Service
function getStateCode(recordId) { // Service Url var serverUrl = Xrm.Page.context.getServerUrl(); var dataServiceUrl = serverUrl + "/XRMServices/2011/OrganizationData.svc"; // sanitize recordId recordId = recordId.replace("{", ""); recordId = recordId.replace("}", ""); // create select query var oDataSelect = dataServiceUrl + "/LeadSet?$filter=LeadId eq guid'" + recordId + "'"; // create request $.ajax({ type: "GET", contentType: "application/json; charset=utf-8", datatype: "json", url: oDataSelect, beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Accept", "application/json"); }, success: function (data, textStatus, XmlHttpRequest) { var retrievedLeadState = data.d.results[0].StateCode; // StateCode is an OptionSet so we must use eval-function var stateCode = eval(retrievedLeadState.Value); return stateCode; }, error: function (XmlHttpRequest, textStatus, errorThrown) { alert('OData Select Failed: ' + odataSelect); return false;} }); }
以上是关于crm2011:使用oData(REST)服务端点检索StateCode(Status)的主要内容,如果未能解决你的问题,请参考以下文章