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>");
  • Are you getting folders as search results? Or you meant to search within a specific folder? Please share what you have done so far. – Arsalan Adam Khatri Oct 15 '14 at 14:45
  • I want all items in all of the folders – jimmywhizz Oct 15 '14 at 14:56
  • 1
    <Eq><FieldRef Name='ContentType' /><Value Type='Text'>Folder</Value></Eq> This means you are searching Folder content type items. Thus it will not bring Document content type items. Remove the above <Eq> condition and try.. – Arsalan Adam Khatri Oct 15 '14 at 15:18
  • Nope didn't work – jimmywhizz Oct 15 '14 at 15:19
  • Try where FSObjType=1? – wjervis Oct 15 '14 at 15:29
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>"

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.