BeforeProperties/AfterProperties in Event Receivers – I always forget this

 

I always forget this and when I come to create a new SharePoint Event Receiver I wonder why the BeforeProperties or AfterProperties are sometimes not populated.

The Synergy MOSS blog has a really good post describing exactly what properties will contain a hash table and which will be empty depending on which list type the event is coming from and in which method (e.g. ItemAdding).

Be sure to check out the post here –

http://www.synergyonline.com/blog/blog-moss/Lists/Posts/Post.aspx?ID=25

Here are the tables from the post:

These are the values of the properties in List events:

List BeforeProperties AfterProperties properties.ListItem
ItemAdding No Value No Value Null
ItemAdded No Value No Value New Value
ItemUpdating Original Value Changed Value Original Value
ItemUpdated Original Value Changed Value Changed Value
ItemDeleting No Value No Value Original Value
ItemDeleted No Value No Value Null

And here are the properties available in Library events:

Library BeforeProperties AfterProperties properties.ListItem
ItemAdding No Value No Value Null
ItemAdded No Value No Value New Value
ItemUpdating Original Value Changed Value Original Value
ItemUpdated Original Value Changed Value Changed Value
ItemDeleting No Value No Value Original Value
ItemDeleted No Value No Value Null

Hope this helps! :-)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">