简体   繁体   中英

Retrieve multiple using OData in CRM 2011

I want to retrieve multiple record. Here is my code;

function GetQuoteDetails(quoteId) {
var serverUrl = Xrm.Page.context.getServerUrl();
var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
var odataSetName = "QuoteDetailSet";
var odataSelect = serverUrl + ODATA_ENDPOINT + "/" + odataSetName + "$filter=QuoteId/Id eq guid'" + quoteId + "'";
var jSonArray = new Array();
$.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) {
        if (data && data.d != null) {
            jSonArray.push(data.d);
        }
    },
});
return jSonArray;
}

It returns nothing. But there should be 4 records returned. Where is the problem?

Since this is Asynchronous call, you cannot return from function GetQuoteDetails. For verification either use Console.log or alert to check what is data.d value.

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