XRM-OSS / Xrm-WebApi-Client

A promise-based JavaScript library for the Microsoft Dynamics CRM WebApi - TypeScript type definitions available
https://xrm-oss.github.io/Xrm-WebApi-Client/
MIT License
100 stars 28 forks source link

Return all pages doesn't work. It still returns 5000 items #11

Closed gasyleiss closed 7 years ago

gasyleiss commented 7 years ago
    var search = '%o%';
    var request = {
        entityName:"contact",
        async:true,
        returnAllPages:true,
        fetchXml: "<fetch>" +
                    "  <entity name='contact' >" +
                    "    <all-attributes/>" +
                    "    <filter>" +
                    "      <condition attribute='fullname' operator='like' value='" + search + "' />" +
                    "    </filter>" +
                    "  </entity>" +
                    "</fetch>"
    };
    var response = WebApiClient.Retrieve(request)
                    .then(function (data) {
                        if (typeof(data) == 'object' && data.value.length > 0) {
                            Xrm.Utility.alertDialog(data.value[6000].fullname);
                        }
                    })
                    .catch(function (error) {
                        Xrm.Utility.alertDialog(error.message);
                    });
DigitalFlow commented 7 years ago

Hey @gasyleiss,

Can you check how many records you retrieve by setting

headers: [ { key: "Prefer", value: "odata.maxpagesize=1" }]

on your request?

Kind Regards, Florian

DigitalFlow commented 7 years ago

Hey @gasyleiss,

I suppose this is an issue in fetch xml queries. The paging cookie will be received in the fetchxml response and the paging cookie should also be set in the xml, which is currently not done.

Can you please check, if the following query using queryParams works?

var request = { 
    entityName:"contact",
    async:true, 
    returnAllPages:true,
    queryParams: "?$select=*&$filter=contains(fullname, '" + search + "')"
};

This uses request paging headers instead of the xml ones, which should work.

Kind Regards, Florian

gasyleiss commented 7 years ago

Hello Florian, Sorry for the delay...:)

Best, Njaka

DigitalFlow commented 7 years ago

Hey Njaka,

the latest release (3.0.2) includes an implementation for automatic paging in retrieve by fetchXml requests. The test cases are passing and my tests in CRM were successful.

Please give me some feedback, whether it works for you as well.

Kind Regards, Florian