|
388 | 388 |
|
389 | 389 | var nextLink = GetNextLink(response); |
390 | 390 | 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; |
391 | 396 |
|
392 | 397 | response = MergeResults(parameters._previousResponse, response); |
393 | 398 |
|
394 | 399 | // 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)) { |
396 | 401 | SetPreviousResponse(parameters, response); |
397 | 402 |
|
398 | 403 | resolve(SendAsync("GET", nextLink, null, parameters)); |
399 | 404 | } |
400 | | - else if (pagingCookie && (WebApiClient.ReturnAllPages || parameters.returnAllPages)) { |
| 405 | + else if (parameters.fetchXml && moreRecords && pagingCookie && (WebApiClient.ReturnAllPages || parameters.returnAllPages)) { |
401 | 406 | var nextPageFetch = SetCookie(pagingCookie, parameters); |
402 | 407 |
|
403 | 408 | SetPreviousResponse(parameters, response); |
|
528 | 533 |
|
529 | 534 | var nextLink = GetNextLink(response); |
530 | 535 | 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; |
531 | 541 |
|
532 | 542 | response = MergeResults(parameters._previousResponse, response); |
533 | 543 |
|
534 | 544 | // 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)) { |
536 | 546 | SetPreviousResponse(parameters, response); |
537 | 547 |
|
538 | 548 | SendSync("GET", nextLink, null, parameters); |
539 | 549 | } |
540 | | - else if (pagingCookie && (WebApiClient.ReturnAllPages || parameters.returnAllPages)) { |
| 550 | + else if (parameters.fetchXml && moreRecords && pagingCookie && (WebApiClient.ReturnAllPages || parameters.returnAllPages)) { |
541 | 551 | var nextPageFetch = SetCookie(pagingCookie, parameters); |
542 | 552 |
|
543 | 553 | SetPreviousResponse(parameters, response); |
|
0 commit comments