Upgrade SPItemEventReceiver Farm solution - Sharepoint 2013 to Sharepoint 2019 Modern site

GURUNATHAN MARIAPPAN 1 Reputation point
2022-04-23T15:43:31.057+00:00

Dear Experts,

We have a requirement to migrate/upgrade Event receiver (SPItemEventReceiver) developed in SharePoint 2013 to SharePoint 2019 Modern Site. We need your input on the below queries

  1. Please confirm If Event receiver (Farm solution) is supported in SharePoint 2019 Modern site. I am not referring to Remote event receiver
  2. If supported, post upgrading the code in Visual studio 2019 and deployment, Event receiver doesn't trigger while item adding and item updating events. While debugging the code , debugger doesn't reach to the break point

Thanks
Guru

Microsoft 365 and Office | SharePoint Server | Development
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,486 Reputation points Microsoft External Staff
    2022-04-25T07:37:23.803+00:00

    Hi @GURUNATHAN MARIAPPAN ,
    In a typical Full Trust Code (FTC) / Farm Solution scenario, Event Receivers and List Event Receivers were created with the SharePoint
    Server Side Object Model code and deployed via Solutions. In this scenario, the event receiver code runs on the SharePoint server.
    You can use following script to check get all event receivers attached with a List:

    #Get the web  
    $Web = Get-SPWeb "https://sharepoint.crescent.com"  
       
    #Get the Target List  
    $List = $Web.Lists["Documents"]  
       
    #Retrieve all event receivers associated with the list  
    $List.EventReceivers | Select Id, Type, Assembly, Class | FL  
    

    You can add event receivers by following script

    #Get the web  
    $Web = Get-SPWeb "https://sharepoint.crescent.com"  
       
    #Get the Target List  
    $List = $Web.Lists["Documents"]  
       
    #Retrieve all event receivers associated with the list  
    #$List.EventReceivers | Select Id, Type, Assembly, Class | FL  
       
    $Assembly = "Crescent.DocRestrict, Version=1.0.0.0, Culture=neutral, PublicKeyToken=677b45b1314c252c"  
    $Class= "Crescent.Utilities.DocRestrict.Restrict"  
    Write-Host "Attaching Event Receiver..."  
    $list.EventReceivers.Add("ItemAdding", $Assembly , $Class)  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.