Problem:
I have a document library with an "ItemUpdated" item eventreceiver. Each time I upload a document, the eventreceiver fired 2 times in two different threads, with update conflicts as a concequens.
Cause:
When you use check-in/check-out on your document libraries the check-in action also fires an ItemUpdated event. If found this information here (good article!):
Solution:
We need to check which "ItemUpdated" we deal with ... the one from the check-in or the 'real' one. If found this code on the MS site to check the source of the event:
if (properties.AfterProperties["vti_sourcecontrolcheckedoutby"] == null && properties.BeforeProperties["vti_sourcecontrolcheckedoutby"] != null)
{
//This is when the update event is triggered by
check-in.
}
else
{
//This is triggered by events other than check-in
action.
}
4 comments:
SPEventReceiverBase.DisableEventFiring didnot work ?
SPEventReceiverBase.DisableEventFiring won't work because it's not an event that's triggered from within the code - it's an inherent set of events that are triggered outside of our control by SharePoint.
thanks!
but u can avoid this by following this code snippet approach....
properties.disableeventfiring()
properties.update();
properties.eventfiring();
Post a Comment