Many of you have probably used the Content and Structure Reports tool to generate reports on content in your site. These reports allow you to query on all the pages and documents in your site collection in a specific way; for example, one report we include out of the box is the "Checked Out To Me" report, which quickly shows you all the documents and pages that are checked out to you under a specific location in your site collection. When you run a report, it is aware of your current location in the site collection, and only shows you results from that location. You can scope a report to a single list, a single site (and all the subsites and lists under that site), or your entire site collection.
If you haven't used this feature yet, you should give it a try - just click Site Actions -> View Reports to get a list of reports that we include out of the box. Click any of these to run the report from your current location. Alternately, you can run a report at any location from within the Site Content and Structure tool; simply navigate to any location in the site hierarchy, click the View dropdown, and see the list of reports appear:
Since I am currently at the root of my site collection (see that "Lincoln's Site Collection" is highlighted on the left), if I click the "Checked Out To Me" report, I quickly get a view of all documents and pages that are checked out to me across the entire site collection:
If I drill down deeper into the site collection (say, if I click on the "News" subsite to navigate there) and run the same report again, I will only see the documents and pages that are checked out to me in that site:
Pretty simple, isn't it? Each Content and Structure report is essentially one Collaborative Application Markup Language (CAML) query that runs each time you access the report. You can take a look at the exact CAML query that is being run for each report if you navigate to the Content and Structure Reports list; in the Content and Structure tool, just click "Content and Structure Reports" to get a list of all the reports you have available in your site collection. You can see that the Content and Structure Reports list is just like any other list in SharePoint - so, you can add a new custom report to your site collection simply by adding an item to this list.
The interface for adding (or editing) an item in this list looks like this:
A quick breakdown of these fields:
Writing the CAML query for the report can be sort of painful, especially if you aren't very familiar with the syntax. The good news is that there are some cool tools out there that can really lighten the burden. Some of my favorites include:
I won't go in detail how to use these tools, because they are both quite straightforward and intuitive. They, of course, aren't officially supported by us, but you may still find them useful - I know they have helped me in the past. Additionally, you should check out the CAML node in our SDK to help you learn more syntax.
Before I get into sharing some custom report samples, let me enumarate a few tips, tricks, and caveats that you should keep in mind when playing with the reports list:
Okay; I think that just about covers it. Without further ado, here are some custom reports:
All Items Checked out. We have an "Checked Out to Me" report, but it may be useful to know all items across the site collection that are checked out by anybody.
<Where><IsNotNull><FieldRef Name="CheckoutUser" LookupId="TRUE"/></IsNotNull></Where>
Article Pages with no Rollup Image. You may want to ensure that all your article pages have a rollup image associated with them, so they don't look strange in a Content Query web part alongside other Article Pages that do have rollup images. Here's how you get a list of pages that don't have a Rollup Image associated with them:
<Where><And><IsNull><FieldRef Name="PublishingRollupImage" /></IsNull><Eq><FieldRef Name="ContentType" /><Value Type="Choice">Article Page</Value></Eq></And></Where>
You can easily change "PublishingRollupImage" to another field to run a similar query for whatever field you choose.
All large bitmap images. Say your authors have been getting into the habit of using large bitmap files for their site images, and you want to generate a report that gives you a list of all .bmp files in your site collection that have either a height or a width over 200 pixels, and output them in descending order by file size. This is the query you would use:
<Where><And><Eq><FieldRef Name="DocIcon" /><Value Type="Computed">bmp</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>
Hopefully these examples will get you started with some ideas on how to build relevant reports that filter data in a meaningful way for your application. If not, leave a comment and we'll try to help you out.
Lincoln DeMaris, Program Manager, Web Content Management