Event Receiver does not fire

I wrote an event receiver for a list but it seems not firing when you add/update/delete an item.

I used the following Powershell script to see what event receivers that are attached to this list:

Add-PsSnapin Microsoft.SharePoint.PowerShell
$spWeb = Get-SPWeb -Identity http://yourWebUrl
$spList = $spWeb.Lists[“The List’s Name”]
$spList.EventReceivers | Select Name,Assembly,Type

Turned out there were some older event receivers that are still attached to it.

I then had to use the following script to delete all event receivers for this list:

Add-PsSnapin Microsoft.SharePoint.PowerShell
$spWeb = Get-SPWeb -Identity http://yourWebUrl
$spList = $spWeb.Lists[“The List’s Name”]
$numberOfEventReceivers = $spList.EventReceivers.Count
if ($numberOfEventReceivers -gt 0)
{
for( $index = $numberOfEventReceivers -1; $index -gt -1; $index–-)
{
$receiver = $spList.EventReceivers[$index] ;
$receiver.Delete()
}
}

After deleting the event receivers, deployed my receivers again and it worked like a charm!

 

Advertisements
This entry was posted in SharePoint 2010, PowerShell. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s