Take the 2-minute tour ×

I have a list which has 30 odd columns.

I have attached two event handler to the list. 1. ItemUpdating 2. ItemUpdated

In ItemUpdating event, I am checking one field value for a change.

In ItemUpdating event, I want to do the processing, if value changes. I cann't do comparision here because before properties does not provide old values in the list item.

The processing includes few jobs and sending e-mails after completion.

I am looking for a solution where I can set the bit when field value changes in ItemUpdating. Check this bit if set do the processing in ItemUpdated.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

You will not be able to share values directly, you will have to use a secondary method to persist your data.

The easiest way to do this would be to use the property bag of the list item.

//the list item you want to update (typically SPItemEventProperties.ListItem in an event receiver
SPListItem specialItem = list.Items[0];
specialItem.Properties["some_persisted_key"] = "Some Value here";

Be sure to use SystemUpdate otherwise you run into the danger of creating an endless loop (or disable event firing beforehand as described in that article).

In your ItemUpdated event you can access your value then simply by going for specialItem.Properties["some_persisted_key"].

share|improve this answer
It worked for me. –  SinghPrateek Jul 3 '13 at 2:29
Where would you declare the specialItem? If you do it in ItemUpdating, it wouldn't be available in ItemUpdated so you would be stuck with the same issue. If you try to do it before both events, you would have your properties yet to access the list items. Are you saying to create a field in the list and use that for temp storage between events? Can it be done only in the event receiver code? –  calorie712 Jan 13 at 15:52
Have you tried it @calorie712? It's not about declaring specialItem it's about setting a property on the current list item. ItemUpdating is synchronous while ItemUpdated can be set to asynch or synchronous, hence you could write something into the list item properties in ItemUpdating (do a SystemUpdate) and later get that item properties again. –  moontear Jan 13 at 16:35
Ok, that clarifies things for me. I thought everything happened in the code and you were just kind of creating a temporary item and assigning it a temporary property value so you could use it across events. I understand you need to add a field to your list and you utilize it for storage of data that is usable across events. –  calorie712 Jan 13 at 18:24
Almost, but not quite. Every SPListItem has Properties: msdn.microsoft.com/en-us/library/… (Hashtable). This is not about fields of any kind, it is simply a property bag attached to the list item (SPWeb also have this property bag or SPFarm). This property bag is perfect for storing "system" or temporary stuff, you will never want your users to see. Yes you could create a field for that, but the OP asked about sharing a value between code fragments, no need for a field there. A property is enough with a key only you know. –  moontear Jan 13 at 19:14
show 3 more comments

This is the full solution that worked for me... Thanks so much to @moontear!

It allows me to use the current items property bag and nullifies the key each time so it doesn't retain the value.

public override void ItemUpdating(SPItemEventProperties properties)
    SPListItem currentItem = properties.List.Items.GetItemById(properties.ListItem.ID);

    //I had to null out the key or I would have conflicts the next time the event is triggered
    currentItem.Properties["DateChanged"] = null;

    currentItem.Properties["DateChanged"] = true;

public override void ItemUpdated(SPItemEventProperties properties)
    if (Convert.ToBoolean(Convert.ToBoolean(currentItem.Properties["DateChanged"]))
            //do something
share|improve this answer
Great! Note that the properties only store string values, so it should be "true" or 1 instead of true. I guess it is automatically converted to something "stringy", so just a note. –  moontear Jan 15 at 15:10
add comment

Your Answer


