Export (0) Print
Expand All
5 out of 6 rated this helpful - Rate this topic

How to: Create a remote event receiver

apps for SharePoint

Learn the basics about how to handle, add, and remove events in an autohosted app for SharePoint by using the Office Developer Tools for Visual Studio 2012.

Last modified: January 29, 2014

Applies to: apps for SharePoint | Office 365 | SharePoint Server 2013

  • Visual Studio 2012

  • Office Developer Tools for Visual Studio 2012

  • Web Deploy 2.0 installed on the developer computer. You can install this tool from Web Deploy 2.0.

  • A local installation of Microsoft SharePoint 2013. In addition, the installation must be configured to use OAuth if you want to run the app, for example, to test and debug it. Microsoft SharePoint 2013 is already configured for OAuth if you’re testing an app on a target website that was created from the Developer Site site definition. (You can create such a website in SharePoint 2013 Central Administration.)

Core concepts

Before you create a remote event receiver in an autohosted app, you should have a basic understanding of what apps for SharePoint are and how apps for SharePoint that are auto-hosted, provider-hosted, and SharePoint-hosted differ. You should also understand the fundamental concepts of handling events in apps for SharePoint. The following topics in Table 1 should give you that understanding.

Table 1. Core concepts for creating remote event receivers in an autohosted app

Article title

Description

Apps for SharePoint overview

Learn how to create apps, which are small, easy-to-use solutions for end users, by using the new app model in Microsoft SharePoint 2013.

Important aspects of the app for SharePoint architecture and development landscape

Learn about the model for apps for SharePoint and aspects of its architecture, which include app hosting options, user interface options, the deployment system, the security system, and the lifecycle.

Choose patterns for developing and hosting your app for SharePoint

Learn about the different ways that you can host apps for SharePoint.

Handling events in apps for SharePoint

Learn about autohosted apps for SharePoint and how to develop them.

Handling events in apps for SharePoint

Learn about the different types of events that you can handle in an app for SharePoint and how to implement them.

In a traditional SharePoint solution, you use an event receiver to handle events such as users creating or deleting lists or items in lists. In an app for SharePoint, you use a remote event receiver to handle similar events. Remote event receivers work similarly to regular event receivers except that remote event receivers handle events that occur when an app for SharePoint is on a different system from its host web application.

The following procedure shows how to respond when a user adds an item to the Announcements list in an app for SharePoint. For more detailed information about how to handle remote events, see How to: Create an event receiver for an app for SharePoint.

To handle events that occur to items in apps for SharePoint

  1. In Visual Studio, open Solution Explorer, and then choose the project node of the app for SharePoint.

  2. On the menu bar, choose Project, Add New Item.

  3. In the Templates pane, choose Remote Event Receiver, specify a name in the Name box, and then choose the Add button.

    The SharePoint Customization Wizard appears.

  4. On the Choose Event Receiver Settings page, choose an event receiver type, such as List Item Events.

  5. Set the event source to a list whose events you want to handle, such as Announcements.

  6. In the list of events to handle, select the check box next to each event that you want to handle, such as An item was added, and then choose the Finish button.

    A web application is created with a web service that contains a code file. For more information, see Handling events in apps for SharePoint.

  7. In the code file for the web service, add code that will execute every time the events that you specified occur.

To add or remove event handlers in apps for SharePoint

  1. In Solution Explorer, choose the project node for the remote event receiver.

  2. On the menu bar, choose View, Properties Window, or choose the F4 key to view the Properties window.

  3. In the Properties window, set the properties for only the events that you want to handle to True.

    For example, if you want to respond whenever a user adds a list item, set the value of the Handle ItemAdding property to True. If you don’t want to handle that event, set the value of that property to False.

    Figure 1. SharePoint remote events in Visual Studio

    SharePoint remote events in Visual Studio
  4. If you added an event, add the event-handling code to the code file for the web service as you did with previous events.

    To handle a different type of event, add another remote event receiver to the app for SharePoint. For example, if a remote event receiver handles list item events, you can add another list item event to it. But you must add another remote event receiver if you want to handle list events.

This article demonstrated the basics of handling events in an autohosted app for SharePoint. If you want to handle events that occur to the app for SharePoint itself or you want to review a more detailed example that demonstrates how to handle remote events and app events together, see the following topics.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.