0

I'm working with SPFx framework and I'm trying to get all the list items correlated to a specific list. More in details, in my code, I'm using the get() method to retrieve the items, but this function give me only the first 100 elements. This is the piece of code:

    async () => {
      await this.getConfiguration();
      await this.web.lists
        .getByTitle(lista_Protocollo)
        .get()
        .then(async (l) => {
          this.setState({ listaProtocolloId: l.Id }),...

Considering I am using the ListItemPicker component, anyone can suggest me a way to overcome the issue? Thanks

About the mentioned problem, I've know the existence of the getAll() method, but it's not not suitable in this situation, because I need the Sharepoint list Id. This is an example where I use getAll() method in the solution:

    await this.web.lists
      .getByTitle(lista_Protocollo)
      .items.orderBy("Created")
      .getAll()
      .then(async (res) => {...
Marco
  • 1

1 Answers1

0

I am not sure why .getAll is not working for you. Anyway, you can also use .top function to overwrite the default limit of 100:

sp.web.lists.getByTitle(lista_Protocollo).items.top(2000).get()

If you want to get both list metadata and list items then you need to make two queries (or a batched query)

Nikolay
  • 10,752
  • 2
  • 23
  • 51