Remove event receivers in a SharePoint list

(Applies to: SharePoint On-Premises)

How to remove event receivers in a SharePoint list?

Event receiver instances on a SharePoint list can be removed by either of the methods mentioned below.

#1. Using PowerShell:-

– Below is the Powershell script to get the list of all event receivers present on a list.

Add-PSSnapin Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue

$web = Get-SPWeb -Identity <<Site URL>>
$list = $web.Lists[“<<List Name>>”]
$list.EventReceivers

** replace <<Site URL>> , <<List Name>> place holders in the script as needed.

This will get all the event receivers with their properties (Id, Name etc.) present on this list.

– Identify the Id or Name of the event receiver which should be deleted. Run below PowerShell script to delete a event receiver using Id of an event receiver.

Add-PSSnapin Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue
 
$web = Get-SPWeb -Identity <<Site URL>>
$list = $web.Lists[“<<List Name>>”]
 
$type = "<<Event receiver type>>"

$receiverId =  "<<Event receiver Id>>"

# replace <<Event receiver type>> with event type. eg: ItemDeleting, ItemAdding, ItemUpdating etc.

# replace <<Event receiver Id>> with the id of event receiver.
 
$numberOfEventReceivers = $list.EventReceivers.Count
 
if ($numberOfEventReceivers -gt 0)
{
   for( $index = $numberOfEventReceivers -1; $index -gt -1; $index–-)
   {
      $receiver = $list.EventReceivers[$index] ;
      $name = $receiver.Name;
      $id = $receiver.Id;
 
      if ($id -eq $receiverId)  #similary ($name -eq "event receiver’s name") can be used.
      {
         $receiver.Delete()
         Write-Host "Event receiver " $name " is deleted"
      }
   }
}
else
{
   Write-Host " There is no EventReceivers with Id " $receiverId" registered for this list "
}
 
$web.Dispose()

 

#2. Using SharePoint Manager tool:-

SharePoint Manager is a SharePoint object model explorer. It enables you to browse every site on the local farm and view every property. It can be downloaded from below URL.

https://spm.codeplex.com/

Run SharePoint Manager tool as administrator in the SharePoint server, browse to the target list, expand event receivers section, select the event receiver, right click on it and click delete button to remove the event receiver. Refer sample image below.

Leave a Reply