Advertisements

Current Item Properties for Comparison within the ItemUpdating Event Receiver Event


Within an event receiver, you have two hash tables available to you within SPItemEventProperties, BeforeProperties, and AfterProperties.

When working with the ItemUpdating event receiver, the AfterProperties do indeed hold the updated values of that list item. However, the BeforeProperties hash table does not hold the current item values, which can lead you to some head scratching trying to figure out how to access these for comparison purposes.

Never fear – you can still get to it through the SPItemEventProperties through:

properties.ListItem.Fields[“Field Display Name”].InternalName

So you can compare that with your AfterProperties value:

properties.AfterProperties[properties.ListItem.Fields["Field Display Name"].InternalName]

And you’re good to go.

Advertisements

About Geoff Varosky
Geoff Varosky is a Senior Architect for BlueMetal Architects, based out of Watertown, MA. He has been architecting and developing web based applications his entire career, and has been working with SharePoint for the past 13 years. Geoff is an active member of the SharePoint community, Co-Founder and Co-Organizer of the Boston Area SharePoint Users Group, co-founder for the Boston Office 365 Users Group, co-organizer for SharePoint Saturday Boston and speaks regularly at SharePoint events and user groups.

2 Responses to Current Item Properties for Comparison within the ItemUpdating Event Receiver Event

  1. James Showley says:

    this saved my life. thank you

    • Glad to hear it helped you out!

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: