1

In a Highligthed Content web part, I want only PDF files to display from a certain document library's subfolder. I have the following CAML - it filters all documents from the indicated subfolder (showing all file types). How can I further filter to only show PDF files from this subfolder?

<View Scope='RecursiveAll'>
<Query>
    <Where>
         <Contains>
         <FieldRef Name='FileDirRef'/><Value Type='Lookup'>SUBFOLDERNAME</Value>
      </Contains>
    </Where>
</Query>
</View>
1

1 Answer 1

0

You can use CAML query like this:


<View Scope='RecursiveAll'>
    <Query>
        <Where>
            <And>
                <Contains><FieldRef Name='FileLeafRef' /><Value Type='Text'>.pdf</Value></Contains>
                <Contains><FieldRef Name='FileDirRef'/><Value Type='Lookup'>FolderName</Value></Contains>   
            </And>
        </Where>
    </Query>
</View>

Output:

enter image description here


OR use KQL query like:

Path:"https://contoso.sharepoint.com/sites/siteName/LibraryName/FolderName" filetype:pdf

OR

Path:"https://contoso.sharepoint.com/sites/siteName/LibraryName/FolderName" filetype:pdf IsDocument:true

Output:

enter image description here

2
  • 1
    Thanks, Ganesh - that solution worked great! May 30, 2023 at 13:47
  • Great, glad it worked for you! Keep using this forum for asking any questions related to SharePoint. May 30, 2023 at 13:55

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.