I wanted to display all files which have the property "Job" = "Job1".

How to retrieve list view items using PnP JS and CAML Query?

Here is the CAML Query?

      <FieldRef Name='Job' />
      <FieldRef Name='FileRef' />
      <FieldRef Name='FileLeafRef' />
      <FieldRef Name='ParentUniqueId' />
      <ViewAttributes Scope='RecursiveAll' />
      <Lists ServerTemplate='101' />
                  <FieldRef Name='job' />
                  <Value Type='MultiChoice'>Job1</Value>
                  <FieldRef Name='lastName' LookupId='True' />
                  <Value Type='Lookup'>1</Value>
               <FieldRef Name='LastName2' LookupId='True' />
               <Value Type='Lookup'>1</Value>
            <FieldRef Name='FSObjType' />
            <Value Type='Integer'>0</Value>
  • Do you have issue with getting correct CAML query or getting items using PnPJS? Feb 28, 2020 at 15:34

1 Answer 1


If you have figured out the correct CAML query for your requirements then you can get items from SharePoint using a CAML Query like below:

import { ICamlQuery } from "@pnp/sp/lists";

// build the caml query object (in this example, we include Title field and limit rows to 5)
const caml: ICamlQuery = {
    ViewXml: "<View><ViewFields><FieldRef Name='Title' /></ViewFields><RowLimit>5</RowLimit></View>",

// get list items
const r = await list.getItemsByCAMLQuery(caml);

// log resulting array to console


Get list items using a CAML Query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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