Tag Archive for Events

Temporarily Disable SharePoint Events

Just a quick post to demonstrate how you can disable events (item, list, web and workflow) for the currently running thread.

There are many reasons why you may want to do this, one of which could be for a unit test where you programmatically create a list item, execute tests against it and then as part of the clean up process, delete the list item. If you have an ItemDeleting event defined against the item that prohibits deletions, then you’ll end up with potentially lots of stray unit test files in your library or list. You can use SystemUpdate to perform changes against an item without events firing, but there’s no way out of the box to stop other events from firing, at least not without a little extra coding.

This solution is pretty simple and concise.

First, create a class that inherits from one of the event receiver classes (see SPEventReceiverBase Class.
Read more

Follow

Get every new post delivered to your Inbox

Join other followers: