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.

Danilo
  • 1,759
  • 4
  • 25
  • 47

2 Answers2

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

SharePointMan
  • 3,364
  • 5
  • 33
  • 51
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>
Danilo
  • 1,759
  • 4
  • 25
  • 47