Tuesday, October 30, 2012

Disable event firing - Part 3 (multiple event firing)

In previous posts (Part 1, Part 2), I've demostrated how to disable\enable event firing in event receiver and outside of an event receiver.

Sometimes, you can find yourself in a situation of having multiple event firing in your code, but just can't find the source of event trigger.

Problem may be that you have more than one event receiver of the same kind registered in your project (two ItemAdding receivers, for example).

Solution to this problem is using EventHandlerManager program. With this small app, you can register, or unregister every event to your Sharepoint list. It can be downloaded from Codeplex - search for "speventhandlermanage".

Write link to your Site Collection in the "Site URL" column and press "Load Lists" button.

In the "Site Lists" section you will get the list of all libraries and lists of that Site Collection.

Select the list you want to check for event handlers and press "Show Registered Event Handlers" button on the right side. You will get the list of all event handlers of that list.

If you see more multiple event handlers of the same kind, you've found your problem. Just select all unwanted event handlers (so that you leave only one of each sort) and press "Remove Selected Event Handlers" button.

Multiple event firing problems are gone.

With this application, it is possible to register event handlers also. To do that, select the desired list in the "Site List" section, select the desired event from "Event Type" dropdown and press "Register To Selected Lists" button.

Really simple, but useful tool.

No comments:

Post a Comment