?
Solved

How can I compare before and after values on Item updating/updated

Posted on 2010-01-11
3
Medium Priority
?
882 Views
Last Modified: 2012-05-08
Is there a way that I can compare before and after values of a custom 'people or group' field using an event receiver.

I am currently using the Item_Updating event and cannot seem to get to the custom value from the SPItemEventProperties. All I am getting is null or 1 in the after properties.

I am trying to figure out if the Assigned To field has changed and if so I need to reassign permissions based on the new Assigned To user.
0
Comment
Question by:Naanan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 19

Expert Comment

by:MsShadow
ID: 26291446
IIRC (it's been a while since I created an eventhandler) you can compare the beforeproperties to the current properties of the item to see if something has changed.

So something like item.BeforeProperties["assignedto"] == item["assignedto"];
0
 
LVL 1

Accepted Solution

by:
sumeetgandhi earned 1000 total points
ID: 26368405
Hi,

Try using this. modify as per your needs. Hope it works :)

public override void ItemAdding(SPItemEventProperties properties)

        {

            string toolTipFieldInternalName = "";

            using (SPWeb web = properties.OpenWeb())

            {

                toolTipFieldInternalName = web.Lists[properties.ListId].Fields[TOOL_TIP_FIELD_NAME].InternalName;

 

            }

 

            string urlVal = properties.AfterProperties["URL"].ToString();

            SPFieldUrlValue val = new SPFieldUrlValue(urlVal);

            string desc = val.Description;

            properties.AfterProperties[toolTipFieldInternalName] = desc;

        }


Thanks
Sumeet
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you create your solutions on SharePoint sooner or later you will come upon a request to set  permissions of the item depending on some of the item's meta-data - the author, people assigned as approvers, divisions, categories etc. The most natu…
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question