Créer un site internet

How to resolve the 5000 item limit

0

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.

Add a comment

Anti-spam