SharePoint 2013: Remote Event Receivers

In this first article on “Remote Event Receivers”, we will understand the concept of “Remote Events” & “Remote Event Handlers” which is a newly introduced concept in SharePoint 2013.

What are Remote Events & Remote Event Receivers?

Remote Events are meant to be considered in context of SharePoint Apps only, since the newly introduced SharePoint Apps Model has got restrictions on how the code should be executed in SharePoint Environment.

SharePoint Apps Model restricts the Apps to execute any server side code within SharePoint execution boundaries. But there are scenarios where it becomes really necessary to handle certain Events during the App Life Cycle.

For instance this is an obvious scenario to perform any desired operation like “creating a Global Settings List in Host Web” during App Installation, similarly it is also a valid scenarios where an Email notification needs to send to the App Users with some of the relevant information regarding the app or taking backup of the App Data or Settings on to the Host Web before actually removing the App during App Uninstallation.

Due to such valid business cases, it is necessary to have a mechanism to handle such events from within the Apps and that’s where Remote Event Handler comes into play.

There are broadly two types of Remote Events most likely to be triggered out of an App:

  1. App Events
    • Handle App Installed
    • Handle App Uninstalling
    • Handle App Upgraded

1

  1. List Events : All list events are supported which are kept within SPRemoteEventType enumeration
    • ItemAdding
    • ItemUpdating
    • ItemDeleting
    • ItemCheckingIn
    • ItemCheckingOut
    • ItemUncheckingOut
    • ItemAttachmentAdding

2

The listed events are just a few out of the complete list of Events that are exposed as Remote Events.

For the complete list of Remote Events you can visit SPRemoteEventType Enumeration.

In order to handle all of the above listed Events SharePoint provides following two Handler functions via an Interface “IRemoteEventService”:

3

  1. ProcessEvent: This is “Before or Synchronous” Handler, which executes before any action (like List Item Added/Updated/Deleted) takes place. This is a Two-Way Event Receivers which means it takes instructions from SharePoint based on User Actions (List Items Added/Deleted), Process it and returns back the result to SharePoint. This function has a return type of type “SPRemoteEventResult”.

4

  1. ProcessOneWayEvent: This is “After or Asynchronous” Handler, which executes after any action (like List Item Added/Updated/Deleted) completed. This is not a Two-Way Handler so it will just accept the instructions from SharePoint based on User Actions (List Items Added/Deleted) and does not returns back any result or notification to SharePoint. This function should be mainly employed for operations like Logging, Sending Notifications to App Users and so on.

5

How do Remote Event Receiver Works:

Step1: User Performs Operations that generates an event in SharePoint [Be it App or List Events]

Step2: SharePoint then look for registered Web Service Endpoint designated to handle this event remotely

Step3: Web Service Endpoint process the instructions based on the Event generated from within SharePoint and returns the result back to SharePoint.

In order to perform any action directly from within the Web Service, Web Service Endpoint needs to call Access Control Service to obtain its own signed token.

6

SharePoint provides the TokenHelper.cs Class file which can be used to make request for necessary tokens.

7

That is all for this post on Remote Even Receivers.

Hope you will find it helpful.

In the upcoming articles on Remote Event Receivers we will explore the implementation details and see each of the types of Events Receivers in action.

So sit tight and stay tuned. 🙂

Advertisements

9 thoughts on “SharePoint 2013: Remote Event Receivers

  1. This is really inspiring. I really like to follow your tips.
    Some very good tips that I think everyone would do well to keep in mind.I look forward to
    reading more posts from you. This is great insight to have!
    Thanks for sharing these great tips. Great stuff for getting started.

  2. Thank you for your very useful information. I appreciate that you looked it up to share with us all.
    This is definitely one of the most valuable sites with information that I have seen. Thanks my friend keep of the
    good work I will definitely be looking forward to more information.

  3. Woah! I’m really loving the template/theme of this site.
    It’s simple, yet effective. A lot of times it’s challenging to get
    that “perfect balance” between superb usability and visual appeal.

    I must say you have done a awesome job with this. In addition, the blog loads very fast for me on Safari.
    Exceptional Blog!

  4. I feel that is among the such a lot vital info for me. And
    i am happy reading your article. But want to commentary on few normal things, The
    web site taste is wonderful, the articles is
    truly nice : D. Excellent task, cheers

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