0

I'm trying to fetch items from a specific view of a Sharepoint list in SPFX using @pnp/sp library but I'm unable to do so. I'm able to fetch the view properties and fields of the list. I didn't find anything as such to fetch the items of that view. How will I be able to acheive the same and also my list contains Lookup columns as well.

1
0

Sample test code for your reference.

sp.web.lists.getByTitle('MyDoc2').views.getByTitle("All Documents").get().then((view: any) => {
      sp.web.lists.getByTitle('MyDoc2').getItemsByCAMLQuery({
        ViewXml: `<View><Query>`+view.ViewQuery+`</Query></View>`
      }).then((items: any) => {
        console.log(items);
      });
    })
2
  • Thankyou for your response. The list has Lookup fields as well so, how do I expand those fields using this method getItemsByCAMLQuery? Jun 8 '20 at 9:00
  • If the lookup filed displays in your view, you could get the lookup item id as items[i].TestLookupId, TestLookup is the lookup field.
    – Lee_MSFT
    Jun 8 '20 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.