Reputation: 1
function GetListItemByEndPoint(listName, RESTEndPoint, OnSucess, IsNotList) {
var url = _spPageContextInfo.webAbsoluteUrl + "/" + (IsNotList ? RESTEndPoint : "_api/web/lists/GetByTitle('" + listName + "')/items" + (RESTEndPoint == "" ? '' : "?" + RESTEndPoint));
jQuery.ajax({
url: url,
type: "GET",
headers: { "accept": "application/json; odata=verbose" },
async: false,
success: function (data) {
OnSucess(data);
},
error: function (xhr, status, error) {
alert("Failed to get Report items.\n" + xhr.responseText);
}
});
}
GetListItemByEndPoint("Daily Inputs", "$select=Category,QueryBalanceb_x002f_f,NormalBalanceb_x002f_f,Received,Processed,Queried,Query_x0020_Resolved,Query_x0020_Balance_x0020_c_x002,Normal_x0020_Balance_x0020_c_x00,Client_x0020_Name/Title,Client_x0020_Name/Id,CSM/Id,CSM/Title,CPT/Id,CPT/Title&$filter=(Created ge datetime'" + StartDate + "T20:00:00.000Z' and Created le datetime'" + EndDate + "T20:00:00.000Z')" + (ClientID == '' ? '' : " and Client_x0020_Name/Id eq " + ClientID) + " &$expand=Client_x0020_Name,CSM,CPT &$top=5000",
function (data) {
BindDashboard(data.d.results, TbaleID, staffId, Btype);
}
);
Upvotes: 0
Views: 6970
Reputation: 1
I have an suggetion for this problem , you can fetch data in parts or bunch like code shown above.
const url = "https://{your tanent domain}/sites/{your site name}/_api/web/lists/getbytitle('listname')/items";
const batchSize = 200;
let skipCount = 0;
let allItems = [];
async function fetchItems() {
let hasMoreItems = true;
while (hasMoreItems) {
const requestUrl = `${url}?$select=file/ServerRelativeUrl,LinkFilename,*&$filter={Filter string}&$expand=file&$OrderBy=ID asc&$Top=${batchSize}&$Skip=${skipCount}`;
const response = await fetch(requestUrl, {
headers: {
"accept": "application/json;odata.metadata=minimal",
}
});
const data = await response.json();
allItems = allItems.concat(data.value);
skipCount += batchSize;
if (data.value.length < batchSize) {
hasMoreItems = false;
}
}
// Process allItems array containing all retrieved items
console.log(allItems);
}
fetchItems();
Upvotes: 0
Reputation: 2218
This is the limitation of SharePoint REST API, you cannot get more than 5000 items from single API call.
You can use filtering on columns with such conditions that will return less than 5000 items (with first filter condition).
Also, apply indexing on columns you are using in filtering and sorting: Add an index to a list or library column
Check below threads for more information related to this topic:
Upvotes: 0