Wednesday, March 13, 2013

SharePoint 2013 : Introduction to Event Receivers


I installed the beta version of SharePoint 2013 recently and played around with it. The first impression I had after creating team sites and community sites was “WOW, it looks amazing”. I guess that’s how you react every time you see a new offering of SharePoint J
This is my first post on SharePoint 2013; dedicated to something I use the most within SharePoint implementations, the Event Receivers.

As SharePoint 2013 offers App development as part of Office 365 development suite, which also replaces the traditional sandboxed solutions available in SharePoint 2010, it becomes very easy to create apps and maintain them within SharePoint 2013.

Event receivers are somewhat modified for SharePoint 2013 into two parts, namely 
  • Remote event receivers and
  • App Event receivers 
I will write separately about how to create both of these event receivers in my future posts. In this blog I will explain what they are and how they can be used to suit our business needs.

Remote Event Receivers

These event receivers signify events that occur on items within any list or library. Say addition of an item, update of an item or deletion of an item. They can be synchronous and asynchronous in nature. Microsoft has modified a bit in this version of SharePoint, the way we deal this nature of event receivers. We will see it how later in this post.

App Event Receivers

These event receivers signify the events that occur to the app we are creating. Say app installation, app uninstalling or app upgrading.

As we create a new remote event receiver or app event receiver in Visual Studio 2012, we need a web application where we would be deploying our app. By default the scope of the app will be the host web application mentioned. A web service is added to this web application to handle the events which contains two methods

ProcessEvent()
Handles events that occur before an action occurs, such as when a user adds or deletes a list item

ProcessOneWayEvent().ProcessEvent()
Handles events that occur after an action occurs, such as after a user adds an item to a list or deletes an item from a list

Like in SharePoint 2010, we had synchronous and asynchronous event receivers, in 2013; we have these two methods which deals with the nature of the event receivers.

Many other things remains same the way we used to deal with them in SharePoint 2010 and VS 2010 environment like adding more events within your event receiver solution, changing the event receiver to point to either Document Library or an Announcement list and so on.

I will write more as and when I try new things within SharePoint 2013.

No comments: