Start Eventhandler itemupdating

Eventhandler itemupdating

When working on production servers usually we don’t have all the tools that we have in our own VMs. Power Shell –erroraction Silently Continue $web = Get-SPWeb -Identity

Below are some Power Shell commands to check, add, modify and remove list event receivers. Url "/Lists/" “list name”) $type = "Item Added" #or any other type, like Item Deleting, Item Adding, Item Updating, ...

It goes without saying that you should be very careful when working with event receivers as with everything else in Share Point. Power Shell –erroraction Silently Continue $web = Get-SPWeb -Identity

This will most likely work for 99.9% of all implementations, but why take the risk.

There may be other code working some magic here as well, and by saving off the value and setting it back you do not interfere with anything else that may be going on. All we need to do is wrap our previous code in a Using statement: Viola! Update() fires, we are inside the scope of our Disabled Events Scope class which has disabled event firing.

We'll create a class called Disabled Events Scope: This class is simple and to the point.

We inherit SPItem Event Receiver and IDisposable, SPItem Event Receiver will give us access to the base properties in the event receiver and IDisposable will give us a Dispose method (which comes in handy in a moment).

Next, in our Dispose method, we simply set the value back and you're done.

Now you may ask, why not just set it to false in the constructor and set it to true in the Dispose.

First, we declare a boolean to hold the original value of the Event Firing Enabled property.

Now, in our constructor we save off the Event Firing Enabled value, then set it to false.

Count if ($number Of Event Receivers -gt 0) else $web.