June 13, 2013

Problem with ItemUpdated Event Reciever and Rename Document

While performing any actions in itemUpdated() event reciever, care should be taken how SPListitem is accessed.
Changed item is generally accessed as follows:
SPListItem item = web.GetListItem(properties.ListItem.Url);
It will work fine as long as any modification to document name is not made. But when a document is renamed, accessing listitem as above will throw an Exception of Nativestack.
Reason: ItemUpdated() is asynchronous event. Hence, it is not necessary when code executes, new URl is available.
Instead, access the changes Listitem as follows,

If you have any questions you can reach out our SharePoint Consulting team here.

No comments:

Post a Comment