Skip to content

Commit

Permalink
Explained when appuninstalling event receiver is triggered in dev and…
Browse files Browse the repository at this point in the history
… end-user scenarios
  • Loading branch information
jansenbe committed Dec 3, 2014
1 parent 8d9961d commit 3a815fc
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions Samples/Core.AppPartPropertyUIOverride/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
Notes:
- The custom category that is being looked for in an App Part on app pages is: **“Custom Category 1”** in this example. This category it’s searching on needs to be unique across all App Parts.
- The specialized custom JavaScript file to load if the custom category is found is: **Contoso.OverrideExample.js**
- The **AppUninstalling** event only fires when a user completely removes the app: the app needs to be deleted from the site recycle bins in an end-user scenario. In a development scenario the app needs to be removed from the “Apps in testing” library.

### SPECIALIZED CUSTOM JAVASCRIPT FILE ###
The **Contoso.OverrideExample.js** file is a specially crafted JavaScript file that utilizes jQuery, the **Contoso.AppPartPropertyUIOverride.js** helper library (more on that below) and SP.JS (the SharePoint JavaScript Client Side Object Model (CSOM) to manipulate the App Part property UI at runtime.
Expand Down
4 changes: 4 additions & 0 deletions Samples/Core.EventReceivers/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
return result;
}
```

Note:
* The **AppUninstalling** event only fires when a user completely removes the app: the app needs to be deleted from the site recycle bins in an end-user scenario. In a development scenario the app needs to be removed from the “Apps in testing” library.

Our code runs the centrally located code to see if a list named “Remote Event Receiver Jobs” exists in the host web and, if it does not, it creates it. The code then checks to see if that list has a remote event receiver attached to it for the ItemAdded event and, if it does not, it attaches one.

```C#
Expand Down
6 changes: 6 additions & 0 deletions Samples/Provisioning.ReR/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ private void HandleItemUpdated(SPRemoteEventProperties properties)
```
After the site is provisioned the site request will have its status updated to “COMPLETED” or “ERROR” based on the outcome.


## AppUninstalling event receiver ##
When the app is uninstalled we’re also removing the event receiver. In order to make this work during debugging you’ll need to ensure that you navigate to the “Apps in testing” library and use the remove option on the app. This remove will trigger the app uninstalling event with the proper permissions to remove the created remote event handler. If you just close the browser or uninstall the app from the “site contents” then either the event receiver never fires or the event receivers runs with unsufficient permissions to remove the list added event receiver. The reason for this behavior is differences in app deployment when the app gets side loaded which is what Visual Studio does when you press F5.

When a user uninstalls a deployed app this moves the app to the site's recycle bin and will NOT trigger the appuninstalling event handler. The app needs to be removed from all recycle bins in order to trigger the appuninstalled event.

# SHAREPOINT ONLINE SETUP #

The first step to create the application principal. The app principal is an actual principal in SharePoint 2013 for the app that can be granted permissions. To register the app principal, we will use the “_layouts/AppRegNew.aspx”.
Expand Down
3 changes: 3 additions & 0 deletions Scenarios/Core.EventReceiversBasedModifications/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ private void HandleListAdded(SPRemoteEventProperties properties)
## DEALING WITH UNINSTALL ##
When the app is uninstalled we’re also removing the event receiver. In order to make this work during debugging you’ll need to ensure that you navigate to the “Apps in testing” library and use the remove option on the app. This remove will trigger the app uninstalling event with the proper permissions to remove the created remote event handler. If you just close the browser or uninstall the app from the “site contents” then either the event receiver never fires or the event receivers runs with unsufficient permissions to remove the list added event receiver. The reason for this behavior is differences in app deployment when the app gets side loaded which is what Visual Studio does when you press F5.

When a user uninstalls a deployed app this moves the app to the site's recycle bin and will NOT trigger the appuninstalling event handler. The app needs to be removed from all recycle bins in order to trigger the appuninstalled event.


### Note: ###
If you’ve been experimenting a lot it often helps to test this sample in a clean developer site.

8 changes: 3 additions & 5 deletions Scenarios/Provisioning.SiteModifier/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,9 @@ In order to only remove the app entry in the Recents menu, the following code is
}
```

## AppUninstalling event receiver ##
When the app is uninstalled we’re also removing the event receiver. In order to make this work during debugging you’ll need to ensure that you navigate to the “Apps in testing” library and use the remove option on the app. This remove will trigger the app uninstalling event with the proper permissions to remove the created remote event handler. If you just close the browser or uninstall the app from the “site contents” then either the event receiver never fires or the event receivers runs with unsufficient permissions to remove the list added event receiver. The reason for this behavior is differences in app deployment when the app gets side loaded which is what Visual Studio does when you press F5.

# Dependencies #
- Microsoft.SharePoint.Client
- Microsoft.SharePoint.Client.Runtime
- OfficeDevPnP.Core

When a user uninstalls a deployed app this moves the app to the site's recycle bin and will NOT trigger the appuninstalling event handler. The app needs to be removed from all recycle bins in order to trigger the appuninstalled event.


0 comments on commit 3a815fc

Please sign in to comment.