override SharePoint threshold limit react override SharePoint threshold limit sharepoint query list more 5000 elements sharepoint query list more 5000 documents fix SharePoint List View Threshold Limit Exceeded

How to resolve the 5000 item limit

On 24/01/2022

In javascript


    var firstItems = listLocation.web.getList(listLocation.listUri).items.select('ID').top(1).orderBy('Id').get();
    var lastItems = listLocation.web.getList(listLocation.listUri).items.select('ID').top(1).orderBy('Id', false).get();
	const allMySites  = [];

    if (firstItems.length === 1 && lastItems.length === 1) {
      const firstId: number = firstItems[0].ID;
      const lastId: number = lastItems[0].ID;
      let startId = firstId;
      let endId = firstId + 5000;
      do {
        let mySites: ISite[] = await listLocation.web.getList(listLocation.listUri).items

          .select('ID', 'Title', 'Url')
          .filter(`Id ge ${startId} and Id lt ${endId} and ProprietairesPeople/Id eq ${userId}`)
          .expand('ProprietairesPeople')
          .orderBy('Title')
          .top(5000)
          .getAll(); 

          allMySites.push(...mySites);
          startId = startId + 5000;
          endId = endId + 5000;
      }
      while (endId < lastId);
    }
    return allMySites;


 

Sharepoint REST javascript React

No ratings yet - be the first to rate this.

Managing cookies

fdi-sharepoint.e-monsite.com deposits cookies to improve your browsing experience, measure the website audience, display personalized advertisements, carry out targeted campaigns and personalize the site interface.