简体   繁体   中英

How to get statuscode using Odata in dynamics crm?

By Using Odata Query I am getting the CRM fields. but statuscode is of type OptionSet how do you get that statuscode . I tried the below code its getting Unable to get 0 or Undefined. Could you have any references appreciated.

$.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.
       }
var retrievedLeadState = data.d.results[0].StateCode;

// StateCode is an OptionSet so we must use eval-function
var stateCode = eval(retrievedLeadState.Value);

alert(stateCode);

Ref: CRM 2011: Retrieve StateCode (Status) using oData (REST) Service Endpoint

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM