0

I was wondering if it's possible to write am CAML query in SPO Online that also let's me search elements within folders in a list, so basically a recursive one.

In combination with PnP Powershell I'm able to find elements with this:

Get-PnPListItem -List $targetList -Query "<View><Query><Where><Eq><FieldRef 
Name = 'FileLeafRef'/><Value Type = 
'Text'>Test.txt</Value></Eq></Where></Query></View>"

However, this file is in the 'root' of the list. I'm not able to find test.txt if it lay in a folder.

I googled that CAML queries can have a 'scope' parameter 'query.ViewAttributes = "Scope='RecursiveAll'" that should do the trick. Unfortunately, I found no way to integrate this into PowerShell. In SharePoint 2013 it seems there's the possibility to create the query via the New-Object Microsoft.SharePoint.SPQuery class.

Any ideas or workarounds?

Thanks a lot in advance.

4

Try <View Scope='Recursive'>

ViewScope enumeration

Example,

Get Items Under Folder CAML

3
Get-PnPListItem -List $targetList -Query "<View Scope=`"RecursiveAll`"><Query><Where><Eq><FieldRef 
Name = 'FileLeafRef'/><Value Type = 
'Text'>Test.txt</Value></Eq></Where></Query></View>"

View Element

  • Thank you as well. I was able to successfully query what I intended to. – colonel_claypoo Jul 13 '17 at 6:41

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.