Notes on Event Handlers in SharePoint Add-Ins

In SharePoint 2010 world, most of the custom SharePoint application used EventReceiver. This guy played a vital role during that timeframe. EventReceiver is very simple. You can consider this as based on your trigger event, what action you want to execute – this could be a validation, schema change, item entry, workflow initiation, or even communicate with other application.

In respect to SharePoint Online, we call this as RemoteEventReceiver(RER). Same utilization through different channel. SharePoint Online utilize different DLLs, interface, and the implementation through add-ins.

In this post, I walk through some notes about RemoteEventReceiver(RER).

Provider-hosted Add-ins

Custom code can handle three categories of events in provider-hosted add-ins:

·       List events, such as the adding or deleting of a list on a website.

·       List item events, such as the editing of an item in a list.

·       Add-in events, such as the installation of an add-in.

SharePoint-hosted SharePoint Add-ins do not support event handling, but you can turn a workflow into a kind of list or list item event handler by setting an event to trigger the workflow.

Workflows cannot be triggered by add-in events, so add-in events cannot be handled with a SharePoint-hosted add-in.

Website events and site collection events are not supported in SharePoint Add-ins.


An RER must be a SOAP web service. A web service is added to the web application to handle the remote event that you specified. A remote event receiver is added to the SharePoint Add-in, and the list item event is referenced in the receiver's Elements.xml file that is itself contained in the add-in web feature.

Following two are major DLLs used for RER

  • Microsoft.SharePoint.Client;
  • Microsoft.SharePoint.Client.EventReceivers;

Name of the interface of Remote Event Receiver >> IremoteEventService

Following are two different types of method implemented through RER.

ProcessEvent(SPRemoteEventProperties properties) - // When a "before" event occurs (such as ItemAdding)

ProcessOneWayEvent(SPRemoteEventProperties properties) - // When an "after" event occurs (such as ItemAdded)


Now, how do you debug remote event receiver in a SharePoint Add-in? -  This requires some Azure configuration. Remember, this is onetime configuration only and you do not have to repeat the Azure configuration for every project that has an RER or add-in event. In your visual studio project, you need to select the check box for Enable debugging via Microsoft Azure Service Bus.

A web service is added to the web application to handle the remote event that you specified. A remote event receiver is added to the SharePoint Add-in. The receiver references the web service and the list item event in the event receiver's Elements.xml file.

Common Error Message

"The remote event receiver callout failed. Details: There was no endpoint listening at https://<yourdomain>:PORTNO/<path>/AppEventReceiver.svc that could accept the message." – Root cause of this error is an incorrect address or SOAP action.

SharePoint requires that there be no explicit port in the URL of the handler in production. This means that you must use either port 443 for HTTPS, which we recommend, or port 80 for HTTP.

 And there are many more....Happy learning!

Comments

Popular posts from this blog

How to fix Azure DevOps error MSB4126

How to create Custom Visuals in Power BI – Initial few Steps

SharePoint Admin Center