Content and Structure Reports: Just a CAML Ride Away
For anyone who has looked a little more closely at the Content & Structure section of SharePoint, you'll probably find it doesn't quite do what you were hoping or expected. You may also have wanted to know how to modify these reports or create your own. For those not familiar at all with this area, hopefully this post will give you a little advance warning and information.
Site Actions --> Site Settings gets you to the site settings area, from here you can find the content and structure link:
This area is only applicable to sites with the publishing feature turned on. Anyone familiar with SharePoint will also know that your available settings links will look very different depending on the user logged in, type of site, and features currently enabled.
If you navigate to Content and Structure you will see a familiar tree view on the left where you can select sites, lists, etc. This gives context to the right-hand window where you can look at views and manipulate content in certain ways.
If you click on view: and choose a report, theoretically all items in the current site context and below should be displayed based on the report. Instead of going over all these reports, I'll just look at two of them right now, then you'll get the idea about what you can do moving forward.
First, let's take a look at the Pending Approval report. Notice the description? Here is the CAML that runs this query:
This query is basically traversing from the current site down and looking for document library list types with the Approval Status column containing the vlaue "2", which means "Pending". Here is a sample clip of the XML Schema for this field in the Pages list on one of my publishing sites:
I'm trying to make three points here. One: The description does not match the results of the query. The person who submitted the item for approval is definitely not a part of the query. So, if you think this query will give you all the items you submitted for approval, it won't.
Two: There is visibly lacking a report that shows you what items are pending approval assigned to you for approval. We'll cut SharePoint some slack here because assignment of the approval really lives in a task list, not the document library. A little later I'll show you how we modified the "My Tasks" report to be a little more useful and where can use this to check for items assigned to you for approval.
Three: These reports are completely customizable, including building your own. I'll go into that next.
If you navigate to your site collection's root site and "view all site content" (/_layouts/viewlsts.aspx) you will see a list called the "Content and Structure Reports".
If you click on this list you will see the familiar list of available Content and Structure reports living in this list, complete with access to the CAML queries that drive them. If you click on "Pending Approval" you will see the columns and data used to drive this list. CAML List Type represents the type of list you are querying. This field is empty in this particular report, telling the report to run against all lists of type "Document Library". If you look at the other reports you will quickly notice how they specify certain list types for querying.
Now let's create a new report that actually looks at items pending approval that I submitted, so I can quickly see what items I submitted for approval but have yet to be approved.
I click "New Item" and fill out the basic data and write the CAML query. Here is what my new report list item looks like and below with the CAML query. There can be no spaces or line returns in the CAML. If your CAML is greater than 255 characters you need to change the Content and Structure Reports list's CAML Query column to "multiple lines of text" to allow for larger queries.
Notice my changes to the original query in order to actually see items I submitted? I added an AND clause where the Editor field looks at the current UserID.
I've done something similar with the "My Tasks" report as well. Out of the box this report shows all your current tasks in the contextual site and below, ignoring the status of the task. Although it's great to see how much work you've accomplished, looking at completed tasks isn't very useful most of the time. below is just the CAML query I used in order to filter out "Completed" tasks from the list:
Obviously these reports can be powerful tools. If you have a knack for writing CAML queries you can create some sophisticated and very precise tools for viewing and helping you manage data across your site collection.
I hope this helps,
-Ryan
This posting is provided "AS IS" with no warranties, and confers no rights.
浙公网安备 33010602011771号