Event itemupdating which
This is because you have two classes – one that is handling the Item Updating event and in which the instance level variable is set, and one that is handling the Item Updated event in which the instance level variable is not set.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.Unfortunately, that makes your project like the Titanic.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.It is nice to update Title in Item Adding and Item Updating events since extra Updates are avoided (without Disable Event Firing), and the "Edit Properties view" will already have the Title filled in Some code example to update title based on filename. For working with Title in Lists, ["Title"] needs to be used.Developing a Sharepoint application would have all the fun of a video game, if only you had infinite lives.
With that in mind, Share Point 2010 is like a sea of icebergs – there is a lot going on under the surface that you may not notice until it’s too late.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.I should also point out that I know the difference between a metaphor and simile in case that was bothering you from the opening sentence.Fortunately, there is a relatively simple way to check whether the Item Updating and Item Updated events are firing in response to a check-in outlined in Knowledgebase Article 939307.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.(no updates required since you are changing the value before it gets saved) I would verify that your Event Receiver is attached to the list.Are you able to debug your Event Receiver when you modify an item in the list?I am nothing if not a masterful linguist after a beer or two or more.Hopefully you know about item event receiver if you are having problems with them firing twice.Also note: the Item Updating and Item Updated events that fire in response to the properties being edited from the dialog will always occur, even if the user is not entering or changing any of the values.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.