Wednesday, March 9, 2011

SPItemEventProperties itemupdated beforeproperties is empty

Can't quite get where to use beforeproperties, afterproperties and properties.ListItem? Sometimes is null sometimes is just not you are expecting.
 Here is a neat table with what you should expect where and when in SPItemEventProperties class

Sharepoint List

Event
BeforeProperties
AfterProperties
ListItem
ItemAdding
Null
New  Value
Null
ItemAdded
Null
New Value
New Value
ItemUpdating
Null
Changed Value
Original Value
ItemUpdated
Null
Changed Value
Changed Value
ItemDeleting
Null
Null
Original Value
ItemDeleted
Null
Null
Null



Sharepoint Document Library


Event
BeforeProperties
AfterProperties
ListItem
ItemAdding
Null
Null
Null
ItemAdded
Null
Null
New Value
ItemUpdating
Original Value
Changed Value
Original Value
ItemUpdated
Original Value
Changed Value
Changed Value
ItemDeleting
Null
Null
Original Value
ItemDeleted
Null
Null
Null