Get Total Count of Records in Library

Hello Community,

Would it be possible to get a count of records in a SharePoint Library/List? I want to display a summary value in the form landing page to the administrator.

Thank you!

Hello @DryChips,

You can get the count of records in List or Library control using the code:

fd.control('SPDataTable1').widget.dataSource.data().length

Hmmmm, would it be possible to get the value using a PnpJs library and display this in a HTML control? I want to create a dashboard like card (see below) and display this on the form.

image

@DryChips,

Yes, you can do that with PnP js:

pnp.sp.web.lists.getByTitle("ListName").items.get().then(function(items) {
    return items.length;
}).then(function(count) {
    //pass value to the field or HTML control
});
1 Like

All right, that's great!

Thank you so much.

I looked into the PnpJs documentation but its really hard to understand and find the correct code to do my job. Do you have any tips on this?

@DryChips,

I'm sorry, I don't understand. I shared a code with you to get the count of records in the list. What else are you looking for in PnPjs documentation?

Hi,

what I mean is, how do you understand the PnpJS documentation? When I read it, its hard to understand what its saying and how to use code.

@DryChips,

The PnPjs documentation is pretty straightforward. For instance, you can find the code to get all list items here.

You only need to add pnp to the beginning of the line to call the PnPjs libary from Plumsail Forms:

let items = await pnp.sp.web.lists.getByTitle("ListBame").items.getAll();
console.log(items);