codeflood logo

Revolver and Reporting

When I was creating Revolver, I never had reporting specifically in mind. But as a side effect of allowing quick access to the content tree, and the way in which the find and query commands work, we pretty much have reporting (minus the extensive formatting) built in. What do we normally want to do in a reporting operation? Query the content tree for items based on a certain criterion, and show them somehow. OK, the biggest shortfall to indicate reporting wasn’t at the top of the list during dveelopment is the fact that there isn’t huge support for formatting your report. But due to the text based nature of the command prompt, you can at least export the data and format it with some external tool.

Items created in a range

So let’s have a look at an example. A typical report would be something like “All the items created in a date range”. We could use either the find or the query command to achieve this. First, let’s look at using find.


The parameters you pass to find act like a filter list. The criteria we’re filtering on in this case is the created field which is called “__created”. This field holds date data in the form yyyyMMddThhmmss. Trying to filter treating this as a string would be quite difficult. Revolver introduces “expressions” to allow evaulation of criteria based on a number of options. The expression parameter is “-e”.

The find command to execute would be:

find -e (@\_\_created > 23/4/2008 as date and @\_\_created < 27/4/2008 as date) pwd

In an expression, we have access to the context items fields using a single at (@) symbol. A double at (@@) allows access to attributes of the item such as id, key and name. Also notice in the expression the use of the “as” flag. This makes Revolver treat the data in a certain way for comparisson; in this case, as a date. We can also chain multiple expression conditions together using either “and” or “or”.

The above find command will find any child of the current item that was created between 23 April 2008 and 27 April 2008. If we want to report on all descendents, then use the “-r” parameter as well.

Items created by somebody specifically


Sitecore already has a facility to allow selection of a set of items based on a set of criteria. Unfortunatley Sitecore Query only compares string data and does not perform casting as we’ve done above. But providing the string comparison is adequate and you know the internal data structure of the data type you are comparing, then this may surffice. We can run Sitecore Queries against the content tree using the “query” command. There is a great article over on SDN about Sitecore Query Syntax.

As a simple examle of using query, let’s find all content created by the user “Tina”. Remember to escape your parenthesis so Revolver doesn’t break your argument.

query (*//*\[@__created by = 'sitecore\\Tina'\]) pwd

Sitecore Query also allows some more expressive string comparisons like startswith and contains.

query (*\[contains(@title, 'title')\]) pwd

What content is not live?

What if we want to report on any content that isn’t live? I first started thinking about what field would indicate such a state. Perhaps “__publish”? No. We have to break out of the item, and cross a database. So if we can define a live item as having a version in master and a version in web, that would be pretty close. Of course there would be descrepencies about changes to the item not having been published, but we’ll take our definition here for the purposes of acedemia.

We can use the “find” command to cycle through a set of items (or all items). So we know we’ll start with that. The “command” parameter we pass to “find” can only contain a single command. But this command can be a script. So let’s start with what kind of script we would need to create. We need to, based on the current item, determine if the same item exists in the web database (or other publishing target). Firstly, let’s grab the path of the current item and put it into an environment variable so we can use it in the next command.

set p < pwd

We can “cd” to an item in a different database by prepending the name of the database in the path. For example, we could “cd” from master to web using:

cd /web/sitecore/content/home

So now, all we have to do is prepend “/web” to the path stored in “p” to see if the item exists.

cd /web$p$

If the item is found the path of the item will be printed. If the item is not found, we’ll receive an error message. Create a script with the above 2 commands and call it something logical like “islive”. Then all we do is pass that as the command parameter to find and we get a report of which items are not live.

find -r islive


So you can see from these examples that we have facility to do basic reporting using Revolver. The formatting may not be up to it but I deliberatley have left the command window in Revolver as a text area, so users can easily copy contents from the window and take the output into some other program for formatting and manipulation.

If reporting is something you find valuable, let me know what you’d like to see in Revolver by dropping a line to me at