Madhur Ahuja

Hello

I have to write an event handler, which will change the values of items corresponding to the old value of the item in the list to the new value. Thus, while writing the event handler, I have to search for the items in other list having old value and then change them to the new value.

Which type of event handler should I go for

I guess, I cannot get the old value in the ItemUpdated event, since the event has already been committed.
While, in the ItemUpdating, user can cancel the event.

Any ideas

Thanks,
Madhur



Re: SharePoint - Development and Programming ItemUpdating or ItemUpdated ?

JXJ

I have not tried this, but I do need to do something similar. I was thinking that I could use some sort of cache or temp file in ItemUpdating to store the old values, then get those values in ItemUpdated.

I suppose another method might be to enable versioning on the list. Then in ItemUpdated you can find out the current version and get the values from the previous verison of the list item.





Re: SharePoint - Development and Programming ItemUpdating or ItemUpdated ?

annielhy

Forget properties.cancel

Anything related the previous value should use ItemUpdating

** Get the value from SPListItem[fieldname], NOT beforeproperties





Re: SharePoint - Development and Programming ItemUpdating or ItemUpdated ?

Madhur Ahuja

annielhy wrote:

Forget properties.cancel

Anything related the previous value should use ItemUpdating

** Get the value from SPListItem[fieldname], NOT beforeproperties



Hi

But in ItemUpdating, the event handler will run even if the user cancels the updation.
Isnt it





Re: SharePoint - Development and Programming ItemUpdating or ItemUpdated ?

annielhy

ItemUpdating should run

- after the form is submitted

- before the value is written to DB

right





Re: SharePoint - Development and Programming ItemUpdating or ItemUpdated ?

Madhur Ahuja

Oh, I thought, its run just when the user clicks Edit. Ill try that, thanks

Madhur





Re: SharePoint - Development and Programming ItemUpdating or ItemUpdated ?

fedroponce

You should take a look at this Month's MSDN Magazine article on MOSS Event Handlers... it explains quite well how and when to use each event handler type.

http://msdn.microsoft.com/msdnmag/issues/07/11/OfficeSpace/default.aspx loc=en