0

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 ? <ViewFields> <FieldRef Name='Job' /> <FieldRef Name='FileRef' /> <FieldRef Name='FileLeafRef' /> <FieldRef Name='ParentUniqueId' /> </ViewFields> <QueryOptions> <ViewAttributes Scope='RecursiveAll' /> <Lists ServerTemplate='101' /> </QueryOptions> <Where> <And> <And> <And> <Eq> <FieldRef Name='job' /> <Value Type='MultiChoice'>Job1</Value> </Eq> <Eq> <FieldRef Name='lastName' LookupId='True' /> <Value Type='Lookup'>1</Value> </Eq> </And> <Eq> <FieldRef Name='LastName2' LookupId='True' /> <Value Type='Lookup'>1</Value> </Eq> </And> <Eq> <FieldRef Name='FSObjType' /> <Value Type='Integer'>0</Value> </Eq> </And> </Where>

  • Do you have issue with getting correct CAML query or getting items using PnPJS? – Ganesh Sanap Feb 28 at 15:34
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
console.log(r);

Reference:

Get list items using a CAML Query.

| improve this answer | |

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.