Script is disabled Event Receivers In SharePoint, and How They Can Help You - Portal Integrators
Select Page

Event Receivers In SharePoint, and How They Can Help You

by

To do a specific set of action when something changed on SharePoint components like lists, libraries or even content types, you can create Event Receivers. Event Receiver is a feature in SharePoint to handle events that are triggered when an action happened on SharePoint objects.

One example is when you need to notify a person when a file is uploaded to a document library. Or maybe you would want to record the actions done on a list, have a separate list that will have entries added, every time an item is changed or deleted from a list. Event receivers provide a way to invoke custom processes when these different events are executed.

 

 

You can basically choose from the different types of event receiver.

List Events – Event handling on list definition changes

List Item Events – Event handling on list item actions

List Email Events – Event handling on email-enabled lists

Web Events – Event handling on site operations

List Workflow Events – Event handling on workflow operations

 

Events are classified as asynchronous and synchronous. Synchronous, also known as Before event receivers, fire prior to the event. For example, custom action, like notifying a person, is performed before an item is added to the list. There are cases where you can use this to prevent the event from happening.

 

Below are some examples of the Before Event Receivers:

 

An item is being added (ItemAdding) – This happens before an item is added to a list or a file is being uploaded to a document library.

An item is being updated (ItemUpdating) – This happens while an item is being updated.

An item is being deleted (ItemDeleting) – This happens when an item is being deleted.

 

While asynchronous, are also called as After event receivers. Custom code added here is invoked after an event happens. Unlike the before event receivers that immediately occur before an event, after event receivers may or may not be initiated right after an event.

 

The following are some examples of the After Event Receivers:

 

An item was checked in (ItemCheckedIn) – This happens after a document was checked in.

An item was checked out (ItemCheckedOut) – This happens after a document was checked out.

An item was unchecked out (ItemUncheckedOut) – This happens after unchecking an item in a list.

An attachment was added to the item (ItemAttachmentAdded) – This happens after an attachment was added to a list.

An attachment was removed from the item (ItemAttachmentDeleted) – This happens after an attachment was deleted from a list.

We just listed some examples above but there are a handful of other different events which you can override through custom coding in case you would need to do specific processes during these events. Although applying this or not would still depend on whatever your requirements are, it would still be helpful to know that there are these event receivers that you can use in these cases.

Base Classes

You can inherit from 5 different classes to develop event receivers, depending on which SharePoint object you would want to handle.

,

Asynchronous Events

You can perform custom actions before an event occurs.

+

Synchronous Events

Specific actions can be triggered after an event occurs.

Want More Information on How SharePoint Can Help You