Export (0) Print
Expand All

App event receivers FAQ

apps for SharePoint

Get answers to frequently asked questions about using app event receivers in SharePoint 2013.

Last modified: December 31, 2014

Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Online | SharePoint Server 2013

By now, you’re probably familiar with the feature in SharePoint 2013 called remote event receivers, which enable SharePoint to be notified of changes in data contained outside of the SharePoint installation. However, there is another type of event receiver, called an app event receiver, that can be used to execute code at various stages in an app's life cycle. App event receivers can handle three events: Installed, Uninstalling, and Upgraded. See Handling events in apps for SharePoint for more information.

The following are common questions you may have when using app event receivers.

App event receivers are only supported when you use them in a cloud-only SharePoint Online or Office 365 environment.

You can create handlers for the following events:

  • App Installed: Runs when the app is installed.

  • App Uninstalling: Does not run when the app is removed. Removal of an app only move the app to the user's Recycle Bin. Two more steps are required before the App Uninstalling event is triggered. First, a user must remove the app from her Recycle Bin, which moves it to the second stage Recycle Bin. Second, a user must empty the second stage Recycle Bin. This last task triggers the App Uninstalling event.

  • App Upgraded: Runs when the app is updated.

Yes. Your implementation of the App Installed event must complete and return an SPRemoteEventResult object within 30 seconds or the SharePoint installation infrastructure will think it has failed. The infrastructure will rerun the event, and repeat your code from the beginning, up to four times. After four timeouts, SharePoint will roll back the entire app installation. We recommend the following practices:

  • If there is any code in your handler that should not be repeated after a timeout, put it in a conditional block that tests to see if it has already run. You must test the actual installed component. Simply setting a variable to true when a block of code completes does not work as a test because all variables are reinitialized when the event times out and restarts.

  • Move installation code that takes more than 30 seconds into the app itself. You can add it to "first run" logic that executes the first time the app is launched. Alternatively, the app can prompt the user to run the installation code.

  • If the preceding bullet item is not feasible for your app, another option is to have your event handler start a remote asynchronous process and then immediately return a SPRemoteEventResult object. A weakness of this strategy is that if the remote process fails, it has no way to tell SharePoint to roll back the app installation.

If you are using SharePoint 2013 on-premises, Access Control Service (ACS)—which is responsible for generating tokens—is not used. Therefore no token is generated, and an error occurs. This is by design because, in this case, both SharePoint and the app are within the same firewall. This means that there is a high-trust relationship between them already.

Important note Important

The use of app and remote event receivers is only supported in a SharePoint Online installation.

When installing an app, you might see the following errors:

@"Error 1
CorrelationId: fe79ac5a-d462-44c8-be7b-2dc3b9a89689
ErrorDetail: The remote event receiver callout failed.
ErrorType: Transient
ErrorTypeName: Intermittent
ExceptionMessage: There was no endpoint listening at https://localhost:44303/AppEventReceiver.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. Source: Common
SourceName: Common App Deployment

or

No endpoint listening

If you get one of these errors, open your Visual Studio project and find your AppManifest file. In this file, change ~remoteAppUrl to your actual web app URL—for example, https://myapp.onmyserver.com.

When your app event receiver fires, you may see the following error:

The remote event receiver callout failed. Details: The server was unable to process the request due to an internal error.

To troubleshoot this error, you need more information. You can learn more by either turning on IncludeExceptionDetailInFaults on the server to send the exception information back to the client, or by turning on tracing and inspecting the server trace logs that are generated.

Yes. Remote event receivers (even app event receivers) require an app for the event-handling code. For more info, see Handling events in apps for SharePoint.

There are several things you can do to troubleshoot this problem.

  • The first place to start troubleshooting is in your project properties. Look for the App for SharePoint Events section in the properties window.

  • Next, you can open your AppManifest.xml file in code view and look for the following section.

    <Properties>
    <Title>MyAppTitle</Title>
    <StartPage>~remoteAppUrl/Pages/Default.aspx?{StandardTokens}</StartPage>
    <UninstallingEventEndPoint>~remoteAppUrl/AppEventReceiver.svc</UninstallingEventEndPoint>
    <InstalledEventEndpoint>~remoteAppUrl/AppEventReceiver.svc</InstalledEventEndpoint>
    </Properties>
    

    Ensure that the URLs that are written here map to what your URLs should be.

Show:
© 2015 Microsoft