The ItemDeleted Event

7 בנובמבר 2007

תגיות: ,
אין תגובות

Hi,


This will be short and sweet. I ran into a customer yesterday tried to run a code for handling a Delete event in a document library. He responded to the "Itemdeleted" event and tried to get the SPItem object through the event's variables. However, the SPItem object consistently returned null so he couldn't do anything with it.


Well – this was true in earlier version but today, this issue is fairly simple to resolve. MOSS has both sync and a-sync events in the new programming model. In our case, the ItemDeleted event is not the best one. This event gets fired once the item was already deleted so we can't really reach any of its inner properties or values. You should use the ItemDeleteing event that is much more fit in this scenario. The ItemDeleting event gets fired after a Delete request was received but before the actual Delete operation. This means that your code is bound to commit when the item still exists and the SPItem is still available for use. Seems like a small issue in English grammar but could be very meaningful when you code…


By the way – This is true for all of the "ing" events in MOSS.


Bye,


Adir Ron

הוסף תגובה
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. שדות החובה מסומנים *