Skip to content

Difference between BeforeProperties, AfterProperties and ListItem values

February 1, 2012

Even if it is discussed in MSDN documentation many developers are not familiar with the exact values in the BeforeProperties, AfterProperties and ListItem hashtables when using SPItemEventReceivers. Guessing and experimenting usually works, but that’s not the best way.

These tables (source) summarize what to expect in the different fields both in case of SPList and SPDocumentLibrary:

List
BeforeProperties
AfterProperties

properties.ListItem
ItemAdding
New Null
ItemAdded
New New
ItemUpdating
New Old
ItemUpdated
New New
ItemDeleting
Old
ItemDeleted
Null
Document Library
BeforeProperties
AfterProperties
properties.ListItem
ItemAdding
Null
ItemAdded
New
ItemUpdating
Old New Old
ItemUpdated
Old New New
ItemDeleting
Old
ItemDeleted
Null

Legend:

  • Null: Null value in the hashtable
  • Old: The original value is in the hashtable (before the update or delete)
  • New: The modified value is in the hashtable (after the add or update)
  • – : Not in the hashtable
  • Highlighted field: difference between list and library
Advertisements
Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: