Skip to content

A Few More CAML Reports

June 15, 2010

I’ve been writing a few more CAML reports, so here’s some more code and resources to write your own! Remember, queries can’t have any line breaks for Sharepoint reports.

Large File Sizes:

<Where>
   <Geq>
      <FieldRef Name="File_x0020_Size" />
      <Value Type="Lookup">1000000</Value>
   </Geq>
</Where>

Large JPG Images: (adapted from the ECM Team blog)

<Where>
   <And>
      <Eq>
         <FieldRef Name="DocIcon"  />
         <Value  Type="Computed">jpg</Value>
      </Eq>
      <Or>
         <Gt>
            <FieldRef  Name="ImageWidth" />
            <Value  Type="Integer">200</Value>
         </Gt>
         <Gt>
            <FieldRef  Name="ImageHeight" />
            <Value  Type="Integer">200</Value>
         </Gt>
      </Or>
   </And>
   <OrderBy>
      <FieldRef  Name="FileSizeDisplay" Ascending="False"  />
   </OrderBy>
</Where>

For many of these CAML queries, you’ll find yourself in need of the internal column names – those are the names Sharepoint uses for columns in lists and libraries. For example, Sharepoint displays “File Size”, but to compare file size data, you need to use the internal value File_x0020_Size. A great list of display names, corresponding internal names, and the type used in the <Value> tag can be found in this MSDN article.

Advertisements
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: