1

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:

<Query>
<Where>
<FieldRef Name= 'documentlibrary(2)'>
</FieldRef>
</Where>
</Query>

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

1
  • 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? – Rune Sperre Apr 25 '20 at 19:25
0

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

<View Scope="RecursiveAll">
  <Query>
    <Where>
      <Eq>
        <FieldRef Name="FileDirRef" />
        <Value Type="Text">/full/path/to/your/folder</Value>
      </Eq>
    </Where>
  </Query>
  <OrderBy>
    <FieldRef Name='Modified' Ascending='False'/>
  </OrderBy>
  <RowLimit>6</RowLimit>
</View>

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, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.