0

In SharePoint 2010 I want to execute some code when a list item is updating - when the ItemUpdating event is fired.

What I need is a SPListItem containing the old values (before updating) and another SPListItem containing the new values.

I can easily get the SPListItem with the old values by:

SPItemEventProperties properties;
properties.ListItem;

but I can't get the SPListItem with the new values. The only thing I can get is from

SPItemEventProperties properties
properties.AfterProperties

but that gives me a SPListEventDataCollection. I would like to convert this SPListEventDataCollection into a SPListItem - is that possible?

Thank you

Høgsdal
  • 395
  • 4
  • 21

2 Answers2

4

The updated SPListItem does not yet exist within the ItemUpdating event.

Check this page.

You want to listen in to the ItemUpdat*ed* event and you can get the new ListItem there.

johnnycardy
  • 3,049
  • 1
  • 17
  • 27
0

You could do this...

if (properties.ListItem["title"] != properties.AfterProperties["title"])
{
    //do something because the title has changed
}
calorie712
  • 348
  • 4
  • 14