When you use oddata to obtain CRM data, the default query result contains only 50 records. You can use the "_ next" attribute in the object returned by JSON as a URL loop until the property is empty.
The sample code is as follows:
relatedAccounts = [];function onload() { var serverUrl = Xrm.Page.context.getServerUrl(); var oDataUri = serverUrl + "/xrmservices/2011/OrganizationData.svc/AccountSet?$select=AccountId,Name,&$filter=StateCode/Value eq 0"; GetRecords(oDataUri); var totalRecords = relatedAccounts.length;}function GetRecords(url) { jQuery.ajax({ type: "GET", contentType: "application/json; charset=utf-8", datatype: "json", url: url, async: false, beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Accept", "application/json"); }, success: function (data, textStatus, XmlHttpRequest) { if (data && data.d != null && data.d.results != null) { AddRecordsToArray(data.d.results); FetchRecordsCallBack(data.d); } }, error: function (XmlHttpRequest, textStatus, errorThrown) { alert("Error : has occured during retrieval of the records "); } });}function AddRecordsToArray(records) { for (var i = 0; i < records.length; i++) { relatedAccounts.push(records[i]); }}function FetchRecordsCallBack(records) { if (records.__next != null) { var url = records.__next; GetRecords(url); }}
The sample code in this article is taken from the blog:
Http://lakshmanindian.wordpress.com/2012/12/07/retrieving-more-than-50-records-using-odata-in-crm-2011/