Sharepoint itemupdating andrew j west and amber stevens dating
Simply put, the Item Updating and Item Updated fire twice when adding a document to a library that has the Require Check Out option enabled.
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.
Turning off the Require Check Out option is a great quick fix if you don’t require the item to be checked out in order for it to be edited.
But that option exists to be used, and some people really do need it.
I don’t mean that it’s largest and most luxurious application every written, but rather that you may be cruising headlong into a nasty rendezvous with an iceberg that could deal a severe blow to your project.
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.
Next, let’s look at what happens when the user adds a document when the Require Check Out option is enabled.
If not, kudos to you for tackling the object model with reckless abandon.
If you were to check the document out and edit the properties on the document, you would see the Item Updating and Item Updated events fire once.
Later on, when you checked the document in, you would see those events fire again.
You just have to check to see if the vti_sourcecontrolcheckedoutby property on the item was cleared: This code is using the Before Properties and After Properties on the properties parameter to see what the value of the vti_sourcecontrolcheckedoutby property on the item was before the update occurred, and what it will be after the update has completed.
The vti_sourcecontrolcheckedoutby property identifies who the item is currently checked-out to.
Following is the code for a base class that adds a new parameter to the Item Updating and Item Updated methods that specifies whether the event was called as a result of a check-in operation.