We have event handlers assigned to the list. Lets say when item is added or updated we trigger the event and handle the event by writing our custom code.
The problem happens many times when you require to know that what was the previously entered value if you handle the updating event. Getting the earlier value (before modification done i.e before updated called) in updating is possible so that we come to know that what was the previous value and what is the new changed value of list item.
All you need to do is write a simple code mentioned below:
SPListItem item = properties.ListItem;
string strAmounr = string.Empty;
if (item["Amount"] != null)
{
strAmounr = item["Amount"].ToString();
}
The above code actually gives you the previous value of the Amount column.
Now let's get the new entered value in Amount column of the list.
string strNewAmount = properties.AfterProperties["Amount"].ToString();
Simple!!!! Now you have new value of Amount too. so just compare them and perform your steps.
That's it. your job is done.
2 comments:
this would be magnificent if it actually worked. It's possible that I am trying to get the CHANGED value of a list column in wss; the listItem[] gets the current value, the AFTER and BEFORE properties are nothing. and this just gets values changed in code???
ignore my previous comment, there was an issue with the id10t behind the monitor
Post a Comment