This blog post is a contribution from Jaishree Thiyagarajan, an engineer with the SharePoint Developer Support team.
Let’s first create a SharePoint Hosted App.
Choose “SharePoint-Hosted” option for “How do you want to host your app for SharePoint” in VS 2012.
Now right-click the AppManifest.xml and open with XML editor.
Make sure that you have an internal element within the AppPrincipal element (as shown below).
Here’s my complete AppManifest.xml.
<?xml version="1.0" encoding="utf-8" ?>
Let’s first add a list within the app; so that whenever an item it added, the remote event receiver will be invoked.
Right-click the project and add “New Item”.
Choose List and give it a name, e.g., “MySampleList”.
Now, let’s add a remote event receiver. Right-click solution explorer and click “Add” and then “New Item”. Choose “Remote Event Receiver” and give it a name, e.g., “MyReR” and click “Add”.
Choose the event receiver. For e.g., let’s use “Item was Added” (ItemAdded – Asynchronous) event.
Once you click “Finish”, a web application is created with a web service that contains a code file. If you see the code file of the service, you’d see two methods.
1. ProcessEvent(): This is a synchronous event that handles events that occur before an action occurs. Such as when a user adds or deletes a list item. Two way event that can handle current events (“-ing”) that can callback to SharePoint.
2. ProcessOneWayEvent(): This is a asynchronous event that handles events that occur after an action occurs. Such as after a user adds an item to a list or deletes an item from a list. This is one-way event that can handle past events (“-ed”).
Add the following code to “ProcessOneWayEvent” as we chose to implement the “Item was added” event. The below code just appends the string “changed by RER” to the title of a list item.
public void ProcessOneWayEvent(SPRemoteEventProperties properties)
Uri myurl = new Uri(properties.ItemEventProperties.WebUrl);
using (ClientContext clientContext = new ClientContext(myurl))
if (clientContext != null)
List lstContacts =
int cnt = lstContacts.ItemCount;
ListItem itemContact =
itemContact["Title"] = itemContact["Title"] + " changed by RER";
Now, copy the URL from the properties window of the web application and paste it in the URL section of the elements.xml file of the event receiver of the SharePoint App.
Here’s the URL I see in my properties window.
Your updated XML should look like the one shown below. NOTE: I’ve added the receiver to just one list instance and not to a list template.
<?xml version="1.0" encoding="utf-8"?>
Now, last but not the least, add the below XsltListViewWebPart to the default.aspx page of the SharePoint App, so that we can add items to the list that has been created. Make sure to update the ListUrl property correctly.
<WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly"
ID="full" Title="loc:full" >
runat="server" ListUrl="Lists/MySampleList" IsIncluded="True"
NoDefaultStyle="TRUE" Title="MySampleList" PageType="PAGE_NORMALVIEW"
Now, click F5 and deploy the App. While deploying, you’ll be asked to trust the App. Hit the “Trust It” button.
Try adding items to the list named “MySampleList” and see SharePoint 2013 remote event receivers in action. I’ve added an item “RER is cool”. The remote event receiver changed the title as “RER is cool changed by RER”.
Attaching a sample for you to quickly try SharePoint 2013 remote event receivers Download Zipped SampleSPApp
Here are a few more references on this topic:
How to: Create a remote event receiver
Handling events in apps for SharePoint
SharePoint 2013: Use event receivers to handle events in apps for SharePoint
SharePoint 2013: Create a remote event receiver for external data
If you have not already done so, download and install the Microsoft Office Developer Tools for Visual Studio 2012 tool set for building SharePoint solutions for SharePoint 2010 and SharePoint 2013 using Visual Studio 2012.
Hope this post was helpful!