Please specify what version of the library you are using: [ 1.2.8 ]
Please specify what version(s) of SharePoint you are targeting: [ 2013 ]
I am trying to query recursively all items inside a folder of a SharePoint list. I am adding below the native REST API implementation for what I am trying to achieve:
const viewXml = `<View Scope="RecursiveAll"><Query>${queryText}</Query></View>`;
const url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + listTitle + "')/getitems";
console.log(viewXml);
var queryPayload = {
'query' : {
'__metadata': { 'type': 'SP.CamlQuery' },
'ViewXml' : viewXml,
"FolderServerRelativeUrl": folderServerRelativeUrl
}
};
return $.ajax({
url: url,
method: "POST",
data: JSON.stringify(queryPayload),
headers: {
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"Accept": "application/json; odata=verbose",
"content-type": "application/json; odata=verbose"
}
});
Is there any method in PnP which supports this operation in SP 2013? I see that renderListDataAsStream supports this, but can it work with 2013?
Yes, the getItemsByCAMLQuery method.
Thanks @patrick-rodgers . Replaced with below pnp code and it works. Life is beautiful :-)
const folderServerRelativeUrl=`${_spPageContextInfo.webServerRelativeUrl}/${listName}/${year}`;
const listItems= await pnp.sp.web.lists.getByTitle(listName).getItemsByCAMLQuery({
ViewXml:viewXml,
FolderServerRelativeUrl: folderServerRelativeUrl
});