Monday, June 19, 2006

Event Handlers in MOSS (Sharepoint 2007)

I just saw this amazing video downloaded from the 2007 Office System: How Do I ScreenCasts about event handlers.

did you realize there are now decent event handlers?

The new model actually lets you catch different events in different functions (unlike the 2003 event sinks where you had one sink function and you had to do a switch to identify what type of event it was).

Also, it is now possible to get synchronous events - for example cancel an update to a list item using the itemupdating event.

But more (much more) important than that - the new event handlers support events not just for items (item created,item changed) but also for list (field changed, field deleted, field added, list created, list deleted and so on) and for site (site deleted....).

The only limitation they admit to have is that there is no event handler for sitecreated. This they claim can be done using a feature.

I started thinking about why you should trap a "fielddeleted" event and such like, and ofcourse the answer was list replication. I had lots of applications done around event sinks in 2003 where we defined mirror libraries so that the event sink copied a document once it was uploaded to the mirror libraries. one of the problems was how to change the meta data if the master library was changed. This can solve this issue easily and keep all libraries in synch. ofcourse the copy mechanism doesnt need to be in an event handler in sps2007 - it can be implemented as a workflow step instead, but lets leave this until we develop some best practices as to when to use an event hander and when to use a workflow...


Anonymous said...

Thank you so much for posting the link.. I had been searching aimlessly for so long.. on event handlers...

.NET Dev said...

Event Handler using .NET these are good posts