I am currently working with a custom web part and SharePoint 2013 XSLTListViewWebPart to show documents inside a document library (lets call it DL). I have a field called DocumentStatus inside the document library, and only documents whose DocumentStatus are 'Approved' will show up in the list view.
I also have another field called SubFolderUrl, which will be generated using workflow, and contains the relative URL of a folder (if a folder is added to the document library).
The list view works great on the root level and the first folder level of the document library. However, when a user adds a subfolder (lets call it Y) inside a folder (lets call it X), then the folders inside X (which should be Y) are not displayed on the list view web part (the files inside X are displayed correctly though).
Here is the CAML query I've thrown into the list view:
<View Scope='All' Name='MyViewName'> <Query> <OrderBy> <FieldRef Name='Created' Ascending='FALSE' /> </OrderBy> <Where> <And> <Eq> <FieldRef Name='DocumentStatus' /> <Value Type='Choice'>Approved</Value> </Eq> <Eq> <FieldRef Name='FileDirRef' /> <Value Type='Lookup'>DL/X/Y</Value> </Eq> </And> </Where> </Query> <RowLimit Paged='TRUE'>30</RowLimit> <Aggregations Value='OFF' /> <Toolbar Type='None' /> </View>
First I thought it has something to do with the scope. But when I tried to change the scope from All to Recursive, it returned nothing. When I changed the scope to RecursiveAll, it returned folders and files inside those folders in 1 level (which is not what I expected).
Any ideas on what I am doing wrong here?