0

I want to populate a grid with data from Dynamics CRM. I use fetchXML, to get for each page 10 records. I want to get to the next page, to retrieve the next 10 records. But this isn't happening, I'm using XRMToolbox to simulate the fetch query but it returns me the same results, regardless of the page attribute value.

The fetchXML query is:

<fetch version="1.0" output-format="xml-platform" mapping="logical" count="10" page="1" aggregate="true" distinct="false" >
    <entity name="webpage" >
        <attribute name="url" groupby="true" alias="url" />
        <attribute name="webpageid" aggregate="count" alias="top" />
        <order descending="true" alias="top" />
    </entity>
</fetch>

If I change the page attribute value, say to 10 the response won't be different. Can anyone help me with this?

UPDATE

After many tests with XRMToolbox I've come to conclusion that this query won't listen, whatever page I provide to it. This is because of the aggregate attribute. If I remove it and of course remove the count aggregate, then changing the page attribute will actually fetch for me the next page results.

So in summary page attribute doesn't like the aggregate attribute. Maybe this can work with paging cookies, but I haven't tested it yet, I will test it and update this post.

gdyrrahitis
  • 5,598
  • 3
  • 23
  • 37

1 Answers1

1

To implement paging you need to use not only page number/records per page attributes but paging cookie as well. This msdn article provides all code you need to implement paging.

Andrew Butenko
  • 5,048
  • 1
  • 14
  • 13
  • Thanks for your answer. I thought so, but, before posting this question I've searched for some answers. I've found this article. http://truenorthit.co.uk/2014/07/19/dynamics-crm-paging-cookies-some-gotchas/ Here, the author describes fetchXML paging, but by the end of the article he writes "Don’t use the paging cookie. You can just specify the page and this will work correctly". That had me wondering. Is this innacurate? – gdyrrahitis Oct 13 '15 at 07:24
  • You can try on your own risk. During my work with CRM (7 years at the moment) paging was the only answer. – Andrew Butenko Oct 13 '15 at 14:00
  • 2
    From my experience with CRM and fetching with paging, I've found that the only time you don't want to use the paging cookie is if your query involves a 1-to-many join, in that case you can't send the paging cookie or you will potentially lose records from one page to another, this was confirmed by Microsoft in a support case. Aside from that, I always use the paging cookie with the page number. – AK3800 Dec 15 '16 at 21:08