Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetchAll still returns no more than 5000 items #80

Closed
Suxsem opened this issue Nov 26, 2020 · 8 comments
Closed

fetchAll still returns no more than 5000 items #80

Suxsem opened this issue Nov 26, 2020 · 8 comments
Assignees
Labels

Comments

@Suxsem
Copy link

Suxsem commented Nov 26, 2020

Hi, I'm trying to retrieve all records from a fetchXml but I always get 5000 records despite i'm using the executeFetchXmlAll method.
This is the code I'm using

    const fetch = `
<fetch no-lock="true">
  <entity name="alt_categoriaprodotto" >
    <attribute name="alt_name" />
    <attribute name="alt_markup" />
    <attribute name="alt_livello" />
    <attribute name="alt_categoriapadreid" />
    <order attribute="alt_name" />
  </entity>
</fetch>
      `;

    return CommonDAO.getWebApi().fetchAll("alt_categoriaprodottos", fetch);

where CommonDAO.getWebApi() returns
new DynamicsWebApi({ webApiUrl: baseUrl + "/api/data/v9.0/" });

I found a similar issue here ( #79 ), but I'm not using the useEntityNames parameter.

Thank you

@Suxsem
Copy link
Author

Suxsem commented Nov 26, 2020

I found the issue!

I was searching through the library code when I found this line:

fetchXml = fetchXml.replace(/^(<fetch)/, replacementString);

that contains this regex: /^(<fetch)/

The problem was that my fetchXml string actually started with a new line! I removed the starting new line and now it works.

Maybe you can think about handling this edge case.

Thank you for the library!

@Suxsem
Copy link
Author

Suxsem commented Nov 26, 2020

Umh, something else is wrong.

Now i get the @Microsoft.Dynamics.CRM.fetchxmlpagingcookie annotation in the response but the method always returns 5000 record.

What can i try?
Thank you

@Suxsem
Copy link
Author

Suxsem commented Nov 26, 2020

I think there is something wrong with concurrent requests when one of them is a fetchAll.

Basically, when a fetchAll (with more then 5000 records returned) is running, if you concurrently fire another fetch the results get corrupted.

To reproduce the issue just make one fetchAll (with a fetchxml you expect to return like 20000 records or more) request followed by a normal fetch, without any "then" in order to execute them concurrently. The results of the first fetchAll will not be complete.

Can you please try?

@AleksandrRogov
Copy link
Owner

Yes, I found a concurrency issue in the library, even with new DynamicsWebApi objects. I'm working on a solution.

@Suxsem
Copy link
Author

Suxsem commented Nov 29, 2020

Great, glad you can reproduce it. Thank you for your time! Please don't hesitate to ask me if you need other information or if you want me to test something.

@AleksandrRogov
Copy link
Owner

@Suxsem I fixed the issue. Let me know if the new patch does not fix the issues you reported.

@Suxsem
Copy link
Author

Suxsem commented Nov 30, 2020

Thank you for your effort, I will try it right now

@Suxsem
Copy link
Author

Suxsem commented Nov 30, 2020

Hi @AleksandrRogov it's working great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants