1

I am searching my list but the list is in folders. How can I use a query to ignore the folders and get the whole list so I can search it. I am using sharepoint 2013 and javascript. I want to get all items that are in all folders. None of the folders I have tried this:

        camlQuery.set_viewXml("<View><QueryOptions><ViewAttributes 
Scope='RecursiveAll' /></QueryOptions><Query><Where><And><IsNotNull>
<FieldRef Name='ID' /></IsNotNull><Eq>
<FieldRef Name='ContentType' /><Value Type='Text'>Folder</Value></Eq></And></Where>
</Query></View>");
jimmywhizz
  • 163
  • 1
  • 5
  • 12

1 Answers1

2

You could just use SP.CamlQuery.createAllItemsQuery() as the parameter for getItems() although simply setting the scope to 'RecursiveAll' and inserting the filter that wjervis suggests should also do the trick.

Example of my proposal:

list.getItems(SP.CamlQuery.createAllItemsQuery());

You can inspect exactly what this does in your browser dev tools if you're interested:

>var query = SP.CamlQuery.createAllItemsQuery()
undefined
>query.get_viewXml()
"<View Scope="RecursiveAll">
    <Query>
    </Query>
</View>"
John-M
  • 5,930
  • 3
  • 18
  • 36