I need help writing a CAML. Unfortunately, I have little experience with this and can't seem to formulate a query that works.

I'm trying to show a library that is within another document library. I have document library (1) selected but need the document library (2) within the query to only show those docs. I have this:

<FieldRef Name= 'documentlibrary(2)'>

I also need the query to only show 6 items of the folder and the most recent.

  • Hi, could you try to explain a bit further on how this is set up? It is not possible to have a library inside a library, maybe it is a lookup column? Commented Apr 25, 2020 at 19:25

1 Answer 1


I think maybe you want to filter on a folder inside a library. To do that, use the following syntax:

<View Scope="RecursiveAll">
        <FieldRef Name="FileDirRef" />
        <Value Type="Text">/full/path/to/your/folder</Value>
    <FieldRef Name='Modified' Ascending='False'/>

We have three main parts here, inside the main View tag. That one itself has the scope set to "RecursiveAll" to include all items inside folders.

The Query tag says which items to return. Here we are saying to return anything that has the field FileDirRef(Folder) matching our value string.

OrderBy here is to sort by last modified date, descending (Ascending = False)

Finally, RowLimit is set to only include 6 items. It should be the last 6 modified ones because of OrderBy

Hope this answered your question.

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.