New Event Handlers in SharePoint 2010




With SharePoint 2010, there is now a new host of event handlers that Developers can leverage to interject custom code into their sites when end users perform various actions. To be precise, there are 12 new event handlers available. Notice the chart below, highlighting what is new:

List Events

A field was added

A field is being added

A field was removed

A field is being removed

A field was updated

A field is being updated

A list is being added

A list is being deleted

A list was added

A list was deleted

List Item Events

An item is being added

An item is being updated

An item is being deleted

An item is being checked in

An item is being checked out

An item is being unchecked out

An attachment is being added to the item

An attachment is being removed from the item

A file is being moved

An item was added

An item was updated

An item was deleted

An item was checked in

An item was checked out

An item was unchecked out

An attachment was added to the item

An attachment was removed from the item

A file was moved

A file was converted

The list received a context event

List Workflow Events

A workflow is starting

A workflow was started

A workflow was postponed

A workflow was completed

List Email Events

The list received an e-mail message

Feature Events

A feature was activated

A feature is deactivating

A feature was installed

A feature is being upgraded

Web Events

A site collection is being deleted

A site is being deleted

A site is being moved

A site is being provisioned

A site collection was deleted

A site was deleted

A site was moved

A site was provisioned

Of particular interest is the site provisioning event handlers. I believe this greatly opens the doors for corporations to interject their custom site approval or request workflows into SharePoint, and the obvious, run some custom code on a site after it has been provisioned. Notice that now you are no longer depending on "feature stapling" to execute code on a site after it is provisioned. You can now just attach this web event.

If you recall, feature stapling was/is the action of editing the ONET.xml file within a site definition, adding features to the "WebFeatures" element which would auto-activate features upon provisioning. People would use that functionality to execute code upon site provisioning via a feature activating/ed event receiver, but that is now no longer necessary. Much simpler with this new event!!

Another great improvement to event handlers in SharePoint 2010 is with the improvements to Visual Studio 2010, and what it takes to create them. Notice, when you add a new item into a Visual Studio project, three is an Event Receiver template you can choose from:

When you choose that template, you get a dialog box allowing you to choose what event you want to capture, as well as what content type you want to associate the event receiver with:

After you click finish it will stub out all the code for you! Very slick!

Also notice how Visual Studio 2010 will also stub out all the necessary features and Solution Packages necessary to deploy into SharePoint. Literally all you have to do is hit F5, and then navigate into SharePoint and unit test your event receiver. SO COOL:

It is really great to see Microsoft place such a significant effort on enabling Developers to customize the product, as well as make it so easy to do so (which is so easily seen with their improvements with Visual Studio 2010). Thanks MS!


Comments

Popular posts from this blog

SharePoint 2007 - Simple Task Dashboard

MERGE transformation in SSIS