How do I use pnp to query a list that is in a different SharePoint but still in my collection?
Hello @smithme,
Please use the following code to get list items from another site.
let web = new Web('SiteURL');
web.lists.getByTitle("ListName").items.get().then(function(items) {
//items array
console.log(items);
});
1 Like
Thank you so much for your help!
1 Like
Is it possible to filter by filename ?
Hello @Chris_Grist,
Yes, you can filter documents that are stored in the library by file name with the following code:
pnp.sp.web.getFolderByServerRelativeUrl("/sites/Main/Shared%20Documents").files.filter("fileName'").get().then(function(files) {
console.log(files)
});
1 Like
If anyone looks at this topic, and has issues with lists only returning 100 items, try the following code:
var web = new Web('SiteURL');
web.lists.getByTitle("ListName").items.getAll().then(function(items) {
console.log(items);
});
2 Likes