BeforeProperties/AfterProperties in Event Receivers – I always forget this

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! :-)

11 thoughts on “BeforeProperties/AfterProperties in Event Receivers – I always forget this

  1. Alexey

    I’ve checked for Sharepoint 2010

    For list:
    ItemUpdating: No Values No Values Original Values.

    ItemAdding – useless event. There no way to check the values in ItemAdding :(

  2. Pingback: SharePoint Event Receiver ItemUpdating Event and Hidden Columns | More Soma Please…

  3. josete

    hi guys, i have a problem and i canĀ“t find a solution for this…maybe you can help me.
    my customer wants use windows explorer view to drag and drop SPListItems, at this point everything is OK, but he wants original values of “Modified” and “ModifiedBy” fields (in source list) be the same values in destiny list. the problem is when you are in windows explorer view and you do a dragNdrop action…modifiedBy field has the user logged in windows.
    i have an eventReceiver for that destiny list to change this values overwritting “itemAdding” and “itemAdded” events and my code looks like :
    if (listItem["Author"] != null)
    { listItem["Editor"] = listItem["Author"];
    listItem.update();}

    when listItem.update is running it through an exception saying windows logged in user has modified that item.

    any ideas??? thank you very much

    1. Alex Post author

      Hi Richard,

      Yes that’s correct you can get the AfterProperties on ItemAdding but only for list items, quite annoying really as often I have needed this when working with a doc lib.

      Thanks for the feedback.

      Cheers

      Alex

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="">