Sharepoint Event Receivers – in general

[Notes from Addison Wesley – Sharepoint 2010 development with Visual Studio 2010]

Events in SharePoint are triggered in response to changes, creation, and deletion of SharePoint features, items, lists, sites, or workflows.

synchronous and asynchronous events

(1) Synchronous events, also called “before” events, are events that are raised right before the actual event happens, such as ItemAdding or ItemDeleting. The actual adding/deleting has to wait until the event is executed. Normally used to validate data. Sometimes has a Cancel parameter passed to them that allow the code to cancel the event.

(2) Asynchronous events, also “after” or “post” events, are mostly used for starting a business process that can occur in parallel with a SharePoint action, because they don’t stop or block execution of the flow.

SPListEventReceiver, SPItemEventReceiver, SPWebEventReceiver, SPEmailEventReceiver, SPWorkflowEventReceiver, (all derived from SPEventReceiverBase)
and SPFeatureReceiver

Each event receiver method with the exception of some events in e-mail event receiver and feature event receiver has a single argument that is derived from the SPEventPropertiesBase.

SPListEventProperties object has two SharePoint specific methods: InvalidateList and InvalidateWeb. In case you modify the list or site you should call either InvalidateList or InvalidateWeb, which invalidates the out-of-date list or site and prepares it to be refreshed.

SPItemEventProperties Object

AfterProperties: Hashtable of string/value pair corresponding to a Sharepoint item after the event has occurred. It’s availale in either XXXUpdating or XXXUpdated.

BeforeProperties: Hashtable of string/value pair corresponding to a Sharepoint item before the event has occurred. It’s availale in either XXXUpdating or XXXUpdated. ONLY available for Document Library.


ListWorkflowEvents: WorkflowCompleted, WorkflowStarted, WorkflowStarting, WorkflowPostponed.

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: