I have no idea why the system deletes the first item and then re-creates it.
Item Added and Item Updating may each be called once, multiple times, or not at all, depending on what method was used to update the document.So when the value of the custom field is calculated, you must use a formula that gives you the same result every time.I wired it to my document library and then tried adding documents to the library in various ways to see what got called.Here are the different sets of events that were called for each test.For more information, see the other posts in this series: I was recently tasked to automatically set a document ID value in a Share Point 2007 document library.
(In Share Point 2010, an excellent document ID feature is included out of the box) I figured it would be easy since Share Point supports calculated columns.
I found most of the bugs I ended up working on with the system I built were related to events being called more than once or not being called at all depending on the method used to add the document to the library.
The different ways of adding a document to a library are: I built a stub event handler class that extended the SPItem Event Receiver and logged a message for each event handler that was called.
The best approach I found was to use the Item Updating event and then force Item Updating to be called by triggering an update in the Item Added event.
My first attempt at the code looked like this: I found that there were circumstances when the column value would not get set or would be cleared and I would get the default value for the column instead.
Item Adding – Item Added Office applications seem to have their own integration that avoids calling the Item Updating/Item Updated methods.