Fired event itemupdating which wasn
The first time the Item Updating and Item Updated events fire it is in response to the document properties changing.The second time they fire it is in response to the document being checked in.We may never know about all of the dangers lurking out there, but today we’re going to cover at least one danger you may encounter while writing event receivers – an annoying issue with the Item Updating and Item Updated events firing twice.
If the user opts to cancel, then only the Item Adding and Item Added events will have fired and the document will be left in a checked out state.
I had already covered all the basic things such as: I even went as far as completely emptying the body of the handler to see that in fact the event was firing twice.
As with any problem, I always try to resolve it through the process of elimination by first isolating the core issue into a test project and therefore out of the primary project I’m experiencing it in because sometimes you can’t see the forest because of the trees. After creating the simple project, the problem was still there. The event wasn’t firing twice for the same list, it was firing for ALL Lists. I took another look at my event receiver I had added via Visual Studio to the project. Yes, I had left the file for the Event Receiver there, and therefore when the feature was activated for the project, the receiver got associated to ALL lists on the site.
To understand why this is happening, let’s first look at what happens when the user adds a document to the library when the Require Check Out option is disabled: So the net result of this is that the document is uploaded and the Item Adding and Item Added events have fired, which is pretty much what you would expect.
Next, let’s look at what happens when the user adds a document when the Require Check Out option is enabled.