Skip to content

Commit 14b00b0

Browse files
Florian KrönertFlorian Krönert
authored andcommitted
Fixed issues
1 parent d1bcb19 commit 14b00b0

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/js/WebApiClient.Core.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,16 +388,21 @@
388388

389389
var nextLink = GetNextLink(response);
390390
var pagingCookie = GetPagingCookie(response);
391+
392+
// Since 9.X paging cookie is always added to response, even in queryParams retrieves
393+
// In 9.X the morerecords flag can signal whether there are more records to be found
394+
// In 8.X the flag was not present and instead the pagingCookie was only set if more records were available
395+
var moreRecords = "@Microsoft.Dynamics.CRM.morerecords" in response ? response["@Microsoft.Dynamics.CRM.morerecords"] : true;
391396

392397
response = MergeResults(parameters._previousResponse, response);
393398

394399
// Results are paged, we don't have all results at this point
395-
if (nextLink && (WebApiClient.ReturnAllPages || parameters.returnAllPages)) {
400+
if (moreRecords && nextLink && (WebApiClient.ReturnAllPages || parameters.returnAllPages)) {
396401
SetPreviousResponse(parameters, response);
397402

398403
resolve(SendAsync("GET", nextLink, null, parameters));
399404
}
400-
else if (pagingCookie && (WebApiClient.ReturnAllPages || parameters.returnAllPages)) {
405+
else if (parameters.fetchXml && moreRecords && pagingCookie && (WebApiClient.ReturnAllPages || parameters.returnAllPages)) {
401406
var nextPageFetch = SetCookie(pagingCookie, parameters);
402407

403408
SetPreviousResponse(parameters, response);
@@ -528,16 +533,21 @@
528533

529534
var nextLink = GetNextLink(response);
530535
var pagingCookie = GetPagingCookie(response);
536+
537+
// Since 9.X paging cookie is always added to response, even in queryParams retrieves
538+
// In 9.X the morerecords flag can signal whether there are more records to be found
539+
// In 8.X the flag was not present and instead the pagingCookie was only set if more records were available
540+
var moreRecords = "@Microsoft.Dynamics.CRM.morerecords" in response ? response["@Microsoft.Dynamics.CRM.morerecords"] : true;
531541

532542
response = MergeResults(parameters._previousResponse, response);
533543

534544
// Results are paged, we don't have all results at this point
535-
if (nextLink && (WebApiClient.ReturnAllPages || parameters.returnAllPages)) {
545+
if (moreRecords && nextLink && (WebApiClient.ReturnAllPages || parameters.returnAllPages)) {
536546
SetPreviousResponse(parameters, response);
537547

538548
SendSync("GET", nextLink, null, parameters);
539549
}
540-
else if (pagingCookie && (WebApiClient.ReturnAllPages || parameters.returnAllPages)) {
550+
else if (parameters.fetchXml && moreRecords && pagingCookie && (WebApiClient.ReturnAllPages || parameters.returnAllPages)) {
541551
var nextPageFetch = SetCookie(pagingCookie, parameters);
542552

543553
SetPreviousResponse(parameters, response);

0 commit comments

Comments
 (0)