Query only approuved files

Hello everyone,

Today I will talk about a little trick that a friend gave me recently.

Having used to work with SPQuery, I was already familiar with the attribute needed to query all the file within list’s folder:

 SPQuery.ViewAttributes = "Scope='Recursive'"; 

But recently I learned of another attribute to filter only on documents approved! Indeed there is an attribute “ModerationType” !

 SPQuery.ViewAttributes = " ModerationType='HideUnapproved'"; 

And so if we want to make our request only on our approved documents, we will add the following attributes to our SPQuery.

 SPQuery.ViewAttributes = "Scope='Recursive' ModerationType='HideUnapproved'"; 

Hope this helps!

Christopher.

Tool for CAML Query


Hello everyone,

For those who do not know, there is a tool to generate your CAML queries.

This utility is the work of Karine Bosch and Andy Van Steenbergen

For SharePoint 2003 and 2007 we had the CAML Builder tool, you can it find here: http://www.u2u.be/res/tools/camlquerybuilder.aspx

Recently there was a new version of the CAML Builder targeting SharePoint 2010 and SharePoint Online: CAML Designer.

You can find all information here: http://karinebosch.wordpress.com/my-articles/caml-designer/

If you have to create CAML queries, do not hesitate one second!

Christopher.