Forum Discussion

rjspdev's avatar
rjspdev
Copper Contributor
Aug 24, 2023

SharePoint On-Premises Event Receiver migration to SharePoint Online

Hello, There is a requirement to migrate SharePoint On-Premises sites to SharePoint Online (SPO). Some of the customization in the current 2013 on-prem site include Event Receivers specially ItemDeleting synchronous event. I was checking out SharePoint Webhooks but looks like sync (ing) events are not supported.

Do we have any other option to move Event Receiver in SPO Modern experience specially synchronous events?

Thank you.

  • rjspdev Yes, SharePoint web hooks don't support sync events.

     

    Check if Remove Event receivers in SharePoint online helps.


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

  • We start using Remote Event Receivers + Azure Functions a few years ago to check and block ItemDeleting events. It was tricky to get the response right, but it works quite well.

     

    In a nutshell, it is:
    1. Provide something which can handle HTTP POST from SPO (e.g. an Azure Function)
    2. Use Add-PnPEventReceiver and point to the URL of (1)

     

    Depending on what your Event Receiver should do, it might be necessary to access SP from your code -> CSOM or Graph API. When using *ing events, it is important to return the correct response. Here's a snippet to give you an idea of the response:

    string responseString =
                    $"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body>" +
                    $"<ProcessEventResponse xmlns=\"http://schemas.microsoft.com/sharepoint/remoteapp/\">" +
                    $"<ProcessEventResult xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">" +
                    $"<ChangedItemProperties xmlns:a=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">" +
                    $"</ChangedItemProperties>" +
                    $"<ErrorMessage>{this.ErrorMessage ?? string.Empty}</ErrorMessage>" +
                    $"<RedirectUrl>{this.RedirectUrl ?? string.Empty}</RedirectUrl>" +
                    $"<Status>CancelWithError</Status>" +
                    $"</ProcessEventResult></ProcessEventResponse></s:Body></s:Envelope>";

     

    This articles might help too:
    https://spblog.net/post/2021/09/14/how-to-use-remote-event-receivers-with-net-core-or-net-5-and-pnp-framework
    https://www.linkedin.com/pulse/sharepoint-remote-event-receivers-using-azure-function-rakhi-jain

Resources