locked
REST record limit of 50 has messed up my development - need a solution. RRS feed

  • Question

  • I have a situation - I have over 800 records of orders that I need to calculate the total figure in the Price field on a form. I know that with REST you can get the top 50 results. How do I get the other 750 records?

    I'm trying to get the sum of all 800 records.

    Thursday, July 18, 2013 10:53 AM

All replies

  • You can find an example in SDK on how to return the rest of the data, but I think that a simple Web API controller is a better solution. You could calculate the sum with server side code, and call the controller with a couple of jquery lines.

    From SDK: If there are more than 50 records, there will be a <link rel="next" href="<url to next set of records>" > node in XML or a JSON __next property at the end of the result set. You can use the URL value in that node or property to continue with the next set of records. The URL contains a $skiptoken parameter that provides information about the paging boundary.


    Zarko


    • Edited by Radevic Thursday, July 18, 2013 11:03 AM Additional info
    Thursday, July 18, 2013 11:00 AM
  • Yeah, that's exactly what I am trying to do - with json/jquery/REST. But I haven't found a solution to retrieve all records. I've looked at the SDK but can't find anything specific. Where do I go from here?
    Thursday, July 18, 2013 11:03 AM
  • I meant that you can create a web site (MVC or Forms), host it on the same server as CRM, and include a Web API controller with one method. Ther you can do the calculation, and in javascript on CRM form, just call that controller with help of jquery. You can find a simple example of web api at http://www.asp.net, as well as calling it from jquery.

    Zarko

    Thursday, July 18, 2013 11:07 AM
  • Thursday, July 18, 2013 11:11 AM
  • I'm using CRM Online; so both solutions are not possible. Surely there must be a way to do it online?
    Thursday, July 18, 2013 11:50 AM
  • Something like this?

    function GetData(url) { if (url == null) { url = ServerURL + "/XRMServices/2011/OrganizationData.svc/AccountSet()"; } $.ajax({ dataType: "json", url: url, success: GetResults, error: function () { alert("Error Retrieving Data"); } }); } function GetResults(retrieveReq) { //process the 50 records here

    if (retrieveReq.d.__next != null) { GetData(retrieveReq.d.__next); } else { //finish up here } }

    Initial call:

    GetData(null);


    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Thursday, July 18, 2013 12:12 PM
    Moderator
  • Use report.

    Regards Faisal

    Thursday, July 18, 2013 12:37 PM