In this fourth article in the series on Remote Event Receivers, we will look into some of the applicable business cases around the Remote Event Handlers.
You can reach the previous three articles in this series through the following links:
- SharePoint 2013: Remote Event Receivers
- SharePoint 2013: How to develop Remote Event Receivers for App Events
- SharePoint 2013: How to develop Remote Event Receivers for List And List Item Events
We will investigate the working of the following scenarios which are quite obvious while working with SharePoint List & List Items.
Scenario 1: How to restrict users to delete a certain item
In order to show case this scenario let’s consider an Item “Product-001-1” added to the List called “Products” as shown below:
Now let’s try to delete this item as highlighted below-


As soon as the user tries to delete the item SharePoint looks for any registered Event Receiver with the List and looks for its Receiver Definition to see what events this Receiver is allowed to receive and executes it.
In our case we have registered the following Receiver Definition with the list-

Let’s investigate the code for registering Remote Event Handler –
Since this is a Before Event (as explained in one of the earlier post “SharePoint 2013: Remote Event Receivers”), we need to write the Code in “ProcessEvent” Method.
- Step 1 is to check the type of Event that triggers this Event Receiver by making use of “SPRemoteEventType” Enum and “EventType” Property of the “SPRemoteEventProperties” object.
- Step 2 is to check the List Title by making use of “ItemEventProperties”collection of “SPRemoteEventProperties” object and ensure that we are handling Delete Events received only from a specific case which in our case is “Products”.
- Step 3 is to check for the desired condition and if satisfied then set “ErrorMessage” and “Status” properties exposed by “SPRemoteEventResult”object.
In this case we have set a user friendly message and set status to “CancelWithError”. For all the valid status values we can look for “SPRemoteEventServiceStatus” Enum.
- Step 4 is to return the SPRemoteEventResult object back to SharePoint

The setting we did in Step 3 will let SharePoint terminate the event raised due to user action and return the error message to SharePoint which would be rendered as Error Message for the user as highlighted below-








Prashant BansalPosted Jul 14, 2017, 12:42 PM
Partha, you can find the current logged in user based on the SPWeb Object properties. If still not able to find I will send you the specific code snippet.
Prashant BansalPosted Jul 14, 2017, 12:40 PM
Glad you all find it helpful
parthasarathy BPosted Jun 19, 2017, 1:24 AM
How to Get current logged in user in Remote event receivers
Asad AliPosted Jun 9, 2016, 8:56 AM
Well written
Kuppurasu NagarajPosted Jun 6, 2016, 12:06 PM
Nice Sharing..
Sonu ChaudharyPosted Jun 6, 2016, 9:48 AM
good one...
RajaPosted Jun 6, 2016, 12:32 AM
Nice....
Debasis SahaPosted Jun 6, 2016, 12:21 AM
Good One..
Vignesh ManiPosted Jun 3, 2016, 1:03 PM
Good one