Wednesday, March 11, 2009

Creating a document expiration view

It's a scenario we all know; documentation has to be kept updated, test reports has to be fresh and valid and so on. So how do you ensure that?

Here's a little hint on creating a view that will display items or document that hasn't been updated for a specific period of time.

Create a new view of your list or document library.

Give it a descriptive name and select the fields you want to display

If you got files in folders, select to 'Show all item without folders' under Folders, Folders or Flat

Under Filter select the options that form the criteria for the documents or items you want to look at. In the question about the date, you could use the built in Modified column or use one of your own custom columns, like I do below.
The trick is to use the built-in [Today] feature and the subtract to number of days you want to test for. So, in this case, I looking for documents that has the SKU Test Result set to 'Pass', but has a SKU Test Date that is more than 330 days old. Remember, no spaces in [Today]-330.
The resulting view shows all the documents that needs to be re-tested soon and the responsible person can take the needed actions.

Monday, March 9, 2009

To Dispose or not to Dispose - that's the question

It's a good coding practice to tidy up after yourself to not waste system resources and there's good resources out there to help you learn the techniques. One of my favorites is

But recently I had a workflow that started dying on me and throwing up in the eventviewer with a
.NET Runtime version 2.0.50727.3068 - Fatal Execution Engine Error. The error assumed problems with the dotnet framework, but repairing the framework and applying hot fixes didn't solve the issue. And the strange thing was that it was only when adding new item it happened, where as the workflow ran perfectly when updating items. The major difference was that the item adding was triggered from an eventhandler and therefore ran under the System account, but item updating occurred when a user changed the document. I also discovered that part of the workflow ran, before it died, so I put in excessive logging and ended up at a SPWeb.Dispose line. Once I commented out these lines the error disappeared.

// Disposing here will cause workflow to fail
// web.Dispose();
I'm not a 100% sure this is the right answer, but running in System account seems to prohibit the use of Dispose. Anyway, I left these SPWeb objects to be taking care of by the garbage collector, maybe it was afraid of being unemployed...