1

I have document library in which several folders, in one of them I have sub-folder that I need to display in custom view. So, position of that folder is like Doc.Library > Folder2 > Internet.
I found several examples how to display Folder instead of whole Library in custom view, with help of CAML query in SPD2013.

Here is what I have in my custom view:

<Where> <Contains> <FieldRef Name="FileRef"/> <Value Type="Text">Internet</Value> </Contains> </Where> 

Now comes part which gives me problem, with this query, I get blank page, no documents are visible. If I put Folder2 instead of Internet I see documents but I see all documents of Folder2 folder, which I don't need.
So, my question is how can I manage to show Internet folder only?

I tried several other options, instead of Text to put Lookup, FileLeafRef instead of FileRef, etc. but none were successful.

2
  • Where you are using that caml query? c#? Commented Mar 15, 2017 at 13:59
  • I am using it in .aspx page of Custom view I created for that folder. Commented Mar 15, 2017 at 14:26

2 Answers 2

2

If you are using c#, then you can use the following code

List DocumentsList = clientContext.Web.Lists.GetByTitle(list); CamlQuery camlQuery = new CamlQuery(); camlQuery = new CamlQuery(); camlQuery.ViewXml = @"<View Scope='RecursiveAll'> <Query> <Where> <eq> <FieldRef Name='FileDirRef'/> <Value Type='Text'> /DocLib/Folder2/Internet </Value> </eq> </Where> </Query> <RowLimit Paged='TRUE'> 30 </RowLimit> </View>"; ListItemCollection listItems = DocumentsList.GetItems(camlQuery); clientContext.Load(listItems); clientContext.ExecuteQuery(); 

Ref Click Here

1
  • Thanks for effort and your time. I voted your answer as useful. Commented Mar 15, 2017 at 15:06
0

With minor changes I solved problem.
Instead of FileRef I put FileDirRef. For View I added Scope="RecursiveAll" and for Value I put relative address.

<Where> <Eq> <FieldRef Name="FileDirRef"/> <Value Type='Text'>/sites/sitename/subsitename/DocLibraryName/folderName/SubFolderName</Value> </Eq> </Where> 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.