Pnp Count items in list where items are greater than 5000

I am using a pnp code in order to count a set of items in a list based on a query in order to get a value for the counted items.

//Filter Criteria
filter = "PersonAddressIsOld eq 0 and AddressTypeFk/Id eq 2 and PersonIDfk/Id eq " + fdPersonID + " and ID ne " + intItemIDVal;

//call pnp and check for origine Adddress
pnp.sp.web.lists.getByTitle("Personslist")"Id", "Title", "PersonDetails").filter(filter).get().then(b => {
                    if (b.length > 0) {
                        fd.field('fieldName').value = b.length ;

I will use too the count returned value create other functions.

The problem is that the list has more than 5000 items.
What is the best Pnp syntax or code to count the list items and get the count value where items over than 5000

Hello @gkhadra,

PnPjs uses REST API requests. REST API has its limitations like list views/requests threshold. When working with large lists (more than 5000 items in a view) you must meet certain criteria not to be throttled.

Please see this blog post to learn how to apply filtration to a large list.

1 Like