"the hump, British Slang. a fit of depression or bad humour: to get the hump."
Many months ago I encountered a weird error where content pages in target variations had corrupted text. It all turned out to be an incorrect mapping of Content Types. MOSS Service Pack 1 fixed it, so any page republished after showed the text correctly.
The client got in touch with me recently to say they still had some content pages with the weird characters. Quite a few of their pages hadn’t been re-published yet, but they didn’t know which (they have A LOT of content pages). I was asked to produce a report of the problem pages so the content management people could re-publish them.
This was a bit of an odd problem. What differentiates the corrupted pages from all the other publishing pages in their portal? Well, nothing except the date they were last modified I concluded. I then realised I could provide them with what they need in five minutes flat, using a CAML query.
If you’ve used MOSS, you will have seen the Site Actions -> Reports menu option. You can extend that area with your own reports, and I decided to do that to provide the page update information the client wanted. If you wanted a permanent display of such a report, you might use the CAML I'm going to write below in a Content by Query Webpart (CQWP) instead, but for todays purposes we want an occasional report.
Going to Site Actions -> Manage Content and Structure it was easy to see the ‘Content and Structure Reports’ list. This is where the Reports are, and by adding list items your own reports get created too.
To cut a long story short, this is what I came up with;
I added an item with this rather ungainly title (as you’ll see this report won’t be widely seen!).
All I needed to add was a few configuration settings and a CAML query, and we’re done.
Firstly, I want the query to be limited to Publishing Page. These all reside in the ‘Pages’ library of the variations. As such, I placed <Lists ServerTemplate="850"/> in the CAML List Type field. 850 is the Server Template number for the Pages library. (Magic numbers eh?)
Then I put together my query. I need to find items that were last updated before 15th May 2008, which is roughly when my client installed MOSS SP1. This looked like this;
<Where><Leq><FieldRef Name='Modified' /><Value Type='DateTime'>2008-05-15T00:00:00Z</Value></Leq></Where>
This says to find items Where the Last Modified Date is Less than OR Equal to 15th May 2008. (Btw ‘Modified’ is the internal name for Last Modified Date. )
Finally, I didn’t want just anybody to see this report, as it’s for a specific purpose. I added the Content Management group to the Target Audiences box so that only they will see this query.
It’s not a perfect solution. Some of the pages that come up in the query won’t be goosed, but it sure cuts down the number of pages they need to investigate a lot.
Since MOSS 2007 was released, I’ve been doing a lot of work on the public Sharepoint forums to answer user queries, and help overcome their Sharepoint problems. The vast majority of people want quick-hit non-code solutions to their Sharepoint issues. I hope this posting has demonstrated that custom CAML reports can be just such a quick-hit solution. Brushing up on CAML can pay dividends. Of course, you can also just download one of the CAML generator tools out there! Search for CAML on Codeplex.com and you’ll see what I mean! J
Subscribe to Cloud with a Sunny Outlook
Get the latest posts delivered right to your inbox