Articles tagged with: Event Handlers

Nov20

SharePoint 2010 Event Handler Properties

Written by // Rogério Cruzeiro Categories // Brain Dump

what to use?

  • SPItemEventProperties.AfterProperties
  • SPItemEventProperties.BeforeProperties
  • SPItemEventProperties.ListItem

 

Custom list

 

AfterProperties

BeforeProperties

ListItem

ItemAdding

Changed value

Nothing

Null

ItemAdded

Changed value

Nothing

Changed value

ItemUpdating

Changed value

Nothing

Original value

ItemUpdated

Changed value

Nothing

Changed value

ItemDeleting

Nothing

Nothing

Item

ItemDeleted

Nothing

Nothing

Null

 

Library

 

AfterProperties

BeforeProperties

ListItem

ItemAdding

Nothing

Nothing

Nothing

ItemAdded

Nothing

Nothing

Changed value

ItemUpdating

Changed value

Nothing/Original value

Original value

ItemUpdated

Changed value

Nothing/Original value

Changed value

ItemDeleting

Nothing

Nothing

Item

ItemDeleted

Nothing

Nothing

Nothing

Why two values for the ItemUpdated and ItemUpdating?

When you add a new document to a document library the events fired are in this order: ItemAdding > ItemAdded. Until here nothing new. 
Well right after you add a new document the EditForm pops up in order to allow you to change any properties for the document.
The events that are fired for this Form after you press Save are: ItemUpdating > ItemUpdated.
Yet, at this moment (the moment right after you add a new document), the BeforeProperties has no usefull values like it should. In fact, it has nothing.

So, not only the Update events are fired, when your are adding a new document (because infact the document is already saved), as the BeforeProperties work diferently from the standard Update action.