We’ve been using SharePoint 2007 for over a week now at work. It’s interesting as people are finding annoying things that I’d not encountered as I’ve only been using MOSS 2007 in certain ways when trying to accomplish certain developer type things.
We’ve got a team site setup for every project we’re working on. For one of the projects that we’ve really been using MOSS for we’ve created a wiki library. Every time a new page was added someone was going to the announcements and adding details about the new page. All the announcements were then rolled up into a content by query webpart that we put on the main home page (ie all the different project announcements appeared on one page).
What we wanted to do was have an announcement automatically generated when a new wiki page was added. A simple workflow created in SharePoint Designer seemed an easy way, although I soon gave up on this. It probably can be done but I couldn’t find a way of taking the text “new content added : ” + the title of the wiki page just created. You could added the title of the wiki page created to the announcement title, but you can’t seem to prepend it with anything. If there’s a way to do this please let me know (I must admit I didn’t spend too long looking at it).
The second way of accomplishing this is to use the list events in SharePoint 2007. The event model in SP 2003 only covered document libraries, but the scope has been widened to include lists and some site events as well. Now also events fire before an action occurs. For example as well as ItemAdded event there’s now ItemAdding. This makes it much easier to cancel events before they are just about to happen, rather than trying to roll them back once they have! :-)
You can deploy event handlers in a number of ways. As Features, or programatically using the object model. Here’s a very quick walk through of how to code and hook up an event.
Create a class library in visual studio 2005 called DeletingEventHandler and add a reference to Microsoft.SharePoint.dll (find it at [installed drive]\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI). Add a class called DeleteingAction and add the following code to it.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
namespace DeletingEventHandler
{
public class DeleteingAction : SPItemEventReceiver
{
public override void ItemDeleting(SPItemEventProperties properties)
{
properties.Cancel = true;
properties.ErrorMessage = "Deleting items from " + properties.RelativeWebUrl + " is not supported.";
}
}
}
As you can see the class needs to inherit from SPListItemReceiver. Upon typing public override, you’ll see all the other event handlers you can hook up to. Add a strong key to the library, and build it. Then copy the dll you just built over to the global assembly cache.
Now’s the really cool bit. Patrick Tissegham has created a cool application called WSS v3 EventHandler Explorer that makes it a zillion times easier to assign a event handler to a list or document library. Just browser to the list you wish to add an event to, load your assembly, select your class, give it a sequence number (generally over 10000), and set the event type you want to hook it up to. Click Add Handler and Bob’s your Uncle!
If you have used the code above and deployed it succesfully, go to the list you just assigned the event handler to and try deleting an item from it. Sweet!

So now the pain! Remember the whole point of this was so that when a page was added to a wiki page library an announcement would automatically get created for the site. Well I’ve tried hooking up to the ItemAdded event on nearly every type of list and document library and it seems to work fine except for a Wiki Page Library!!!!!!
How annoying is that! Perhaps it’s a bug, I’m not sure. If anybody else has tried hooking up to a Wiki Page Library and got the events working ok please do let me know!