Skip to content

Commit 34a27a4

Browse files
committed
Adding Slice in RetrieveBatches. For on premise versions it's 100.
1 parent 0e7d46d commit 34a27a4

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
################################################################################
2+
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
3+
################################################################################
4+
5+
/.vs/Dataverse REST Builder/CopilotIndices/0.2.1653.9816
6+
/.vs/Dataverse REST Builder/FileContentIndex
7+
/.vs/DRB/v17

js/drb.xrm.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,17 @@ DRB.Xrm.RetrieveBatch = function (queries) {
188188
* @param {any[]} batchedQueries Batched Queries
189189
*/
190190
DRB.Xrm.RetrieveBatches = function (batchedQueries) {
191+
var MaximumBatchSize = 100;
191192
var xrmCalls = [];
192193
batchedQueries.forEach(function (batchedQuery) {
193194
var queries = [];
194195
batchedQuery.forEach(function (query) { queries.push(query); });
195-
xrmCalls.push(DRB.Xrm.RetrieveBatch(queries));
196+
197+
// Split queries into smaller batches of 100 or fewer operations
198+
for (var i = 0; i < queries.length; i += MaximumBatchSize) {
199+
var batch = queries.slice(i, i + MaximumBatchSize);
200+
xrmCalls.push(DRB.Xrm.RetrieveBatch(batch));
201+
}
196202
});
197203
return $.when.apply($, xrmCalls);
198204
}

0 commit comments

Comments
 (0)