locked
Remote Event Receivers - cannot delete them RRS feed

  • Question

  • Hi

    I am able to create remote event receivers during my app development, however I cannot remove them. I have a large number building up as they are added on deploy.

    I have tried removing them via REST, Client OM both .NET and JavaScript and none work. I have set the app permissions to maximum (except tenancy) and used an external console both with no luck.

    I have office 365 admin, SharePoint tenancy admin, Site collection admin however the error I am getting in all instances is "Access Denied", does anyone have any suggestions why? Or is there a tool I can use to manage them?

    Ideally, I would like the code to remove them on retraction or separate utility.

    Thanks

    SharePoint Dev Guy


    Wednesday, October 16, 2013 3:23 PM

Answers

  • I tried using he AppUninstalled event receiver to remove them. This worked in production, but during development I had issues using the AppUninstalled event with F5 debug - in short, I couldn't get it to work. So in debug if I wanted a clean list, well, I had to delete and recreate it. Hardly ideal.

    How I did removed the event receivers on AppUninstalled for production is described here: http://www.novolocus.com/2014/01/10/register-remote-event-receivers-on-the-host-web/

    • Marked as answer by Dennis Guo Friday, January 17, 2014 1:46 AM
    Thursday, January 16, 2014 4:44 PM

All replies

  • Friday, October 18, 2013 5:38 AM
  • Hi SharepointDevGuy,

    i will try to ask some colleague and do some research regarding this, i will post the result after we have the update.


    Regards,
    Aries
    Microsoft Online Community Support


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Friday, October 18, 2013 3:36 PM
  • Hi SharepointDevGuy,

    we tried this article, and seems ok, http://msdn.microsoft.com/en-us/library/jj220043.aspx

    To add or remove event handlers in apps for SharePoint

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

    2. 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 deletes a list item, set the value of the Handle ItemDeleted property to True. If you don’t want to handle that event, set the value of that property to False.

    3. 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.

    Regarding this issue, we are not quite sure also how you create the remote event receiver, if you create as the same method with the article, then i think the removal process also similar.


    Regards,
    Aries
    Microsoft Online Community Support


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Tuesday, October 22, 2013 10:55 AM
  • I have the same issue - remote event receiver cannot be removed. My receivers are added programmatically to the host web list. If I try to call .DeleteObject() method, I get "Access Denied", which is strange, using the same token I can add the event, but cannot delete it?

    It seems there's no solution for this at this time. Could it be a bug?

    Friday, October 25, 2013 3:09 AM
  • Hi elena,

    i am not quite sure if its an undocumented feature, as this feature most of them are custom coding in unique environment.

    perhaps you can try to debug it, http://msdn.microsoft.com/en-us/library/office/apps/dn275975.aspx

    hoping that able to have clue on what is the authentication that sent.


    Regards,
    Aries
    Microsoft Online Community Support


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Friday, October 25, 2013 7:39 AM
  • Yeah this is exactly the same issue, I'm starting to think this is a bug with SharePoint Online, I found other forum article where people are having the same problem as us:

    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/b965dad9-a770-4075-b9b9-39b304bf23f1/how-to-remove-eventreceiver-when-handling-appuninstalling-in-a-rer-without-getting-access-denied?forum=appsforsharepoint

    Microsoft, is there something here that can be raised as a bug? Or provide guidance/code on what is needed to remove a Remote Event Receiver on a list on the host web?

    Thanks

    SharePoint Dev Guy.

    Friday, October 25, 2013 7:42 AM
  • I have already followed this, the debugging come up with the access denied.

    Its documented here: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.eventreceiverdefinition_methods.aspx

    Thanks

    SharePoint Dev Guy

    Friday, October 25, 2013 7:48 AM
  • Hi SharePoint Dev Guy,

    thank you for the reply,


    for sharepoint online, i am afraid that you need to contact our customer service regarding this, because sharepoint on-premise team dont have the permission to submit or troubleshoot an undocumented feature to the sharepoint online server.

    in the meantime i will try to post also in our on-premiseproduct tool, so that perhaps someone will acknowledge it later, but i cant make any promise or guarantee regarding the process time.


    please contact our customer support for this product:

    http://support.microsoft.com/contactus/


    Regards,
    Aries
    Microsoft Online Community Support


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Friday, October 25, 2013 7:54 AM
  • Hello,

    I have exactly the same problem at this moment. Adding remote event receivers goes fine but deleting them throws up the same exception  as yours after calling ExecuteQuery();

    Have you already found a solution? It's not really breaking anything at this point but it's quite messy!

    (edit: I would like to add that I experience this issue with lists on the host web)

    and the exception:

    ServerUnauthorizedAccessException

    Microsoft.SharePoint.Client.ServerUnauthorizedAccessException was unhandled by user code
      HResult=-2146233088
      Message=Access denied. You do not have permission to perform this action or access this resource.
      Source=Microsoft.SharePoint.Client.Runtime
      ServerErrorCode=-2147024891
      ServerErrorTraceCorrelationId=780c519c-973d-d0af-10de-27b4e3b2e876
      ServerErrorTypeName=System.UnauthorizedAccessException
      ServerStackTrace=""
      
    • Edited by Pieterjan S Monday, October 28, 2013 10:29 AM added exception details
    Monday, October 28, 2013 10:24 AM
  • I've been in touch with someone at microsoft,

    he said the behaviour was as-designed and that a remote event receiver could only be removed by the app that added it (?) haven't tried this yet but I will soon confirm whether this in fact works or not.

    • Proposed as answer by Aries - MSFT Monday, November 18, 2013 2:22 AM
    Tuesday, November 12, 2013 3:01 PM
  • I found this thread as I'm having the same issue. It might be a designed in feature, but it does seem somewhat dangerous - should an App fail to remove it's event receivers, either through poor design or error, couldn't you end up with event receiver definitions that simply can't be removed?

    I'd also be curious as to whether Pieterjan S has had any luck with making this work?

    Tuesday, December 17, 2013 3:23 PM
  • I've just tried this, using the app that added it to remove it from the host web and it gives the same error.

    To clarify:

    1. This is for Remote Event Receivers installed in the HOST web, not the APP web.

    If this behaviour is by design it does not appear to work except in APP webs.

    I look forward to a fix.

    Saturday, January 4, 2014 3:06 PM
  • Further findings show that an App can remove the event receivers it adds in the HOST web but, and here lies the rub, when using Visual Studio to debug each time you retract and deploy it counts as a 'new' App.

    So in production use not an issue but very annoying for development.

    The practical solutions available are:

    1. Code around the issue and if removing fails just continue, sadly you can't update the event receiver properties so if you need to change them you'll have to delete your site and start again.
    2. Use the AppUninstalled event receiver to remove them, probably best practice to clean up after yourself but doing work in the App Event Receivers is a bit of a minefield itself.
    3. Change the deployment so that the App deployment supports Upgrade as well as Remove / Install.  This will need support from Microsoft to accomplish neatly.  Its lack is going to be an issue going forward.

    I'll try using options 1 and 2 in the meanwhile.

    Cheers

    Saturday, January 4, 2014 5:52 PM
  • I tried using he AppUninstalled event receiver to remove them. This worked in production, but during development I had issues using the AppUninstalled event with F5 debug - in short, I couldn't get it to work. So in debug if I wanted a clean list, well, I had to delete and recreate it. Hardly ideal.

    How I did removed the event receivers on AppUninstalled for production is described here: http://www.novolocus.com/2014/01/10/register-remote-event-receivers-on-the-host-web/

    • Marked as answer by Dennis Guo Friday, January 17, 2014 1:46 AM
    Thursday, January 16, 2014 4:44 PM