Answered by:
Event Receiver not firing

Question
-
Can someone explain how event firing works in SharePoint with .Net?
In my itemadded event, i set enableeventfiring to false. The method terminated before I re-enabled event firing.Now no .net events will fire on the farm. All sites. lists and other receivers for the entire farm are no longer firing.
I thought the enableeventfiring=false would affect the item only however it's apparent that when you set enableeventfiring to false, it impacts all events for the entire farm.
Is it possible to enableeventfiring at this point? I could use a code sample or stsadm command to enableeventfiring on the farm.Thanks in advance,
- Edited by jd_hancock Monday, September 24, 2012 1:07 PM
Monday, September 24, 2012 1:05 PM
Answers
-
After a week of not getting the events to fire, it's finally firing. No changes. Just started working. Nice!
Thanks all!- Edited by jd_hancock Thursday, October 4, 2012 7:12 PM
- Marked as answer by Qiao Wei Monday, October 8, 2012 9:57 AM
Thursday, October 4, 2012 7:12 PM
All replies
-
Hi,
You can create a simple console application and use the object model to set this property back to true.
As a sidenote, EnableEventFiring method is obsolete in SharePoint 2010. Its recommended to use the EventFiringEnabled property instead.
Please "Mark as Answer" if a post has answered your question or "Vote as Helpful" if it was helpful in some way. Here's why
Monday, September 24, 2012 1:52 PM -
Hi,
This sounds like you have an extra copy of DLL in your path somewhere, delete old dll and rebuild it.Then make sure that the DLL is no longer in the GAC nor in the bin or _app_bin folders underneath the SharePoint site. Restart IIS. Now redeploy your solution and you should see your breakpoints available again.
http://sharepoint.stackexchange.com/questions/31603/event-receiver-not-firing
http://stackoverflow.com/questions/8588675/sharepoint-event-receiver-not-working
Monday, September 24, 2012 2:20 PM -
Thanks for teh quick response. I was thinking of usnig the console app but have been unable to find the object that contains the method.Monday, September 24, 2012 6:18 PM
-
Hi,
I did a bit of digging around and realized that even if you set EventFiringEnabled=false, events are disabled only for the actions that are going to be performed in the context of that event.
I created an ItemUpdated event receiver as follows -
public override void ItemUpdated(SPItemEventProperties properties) { //this.EventFiringEnabled = false; base.DisableEventFiring(); SPListItem item = properties.ListItem; item["Title"] = "new title from event receiver"; item.Update(); }
As you can see, i am never setting EventFiringEnabled to true. Inspite of that, this and all other events keep firing as expected. Obviously thanks to me setting the EventFiringEnabled to false, the same ItemUpdated event does not fire repeatedly when i call the Update method on the ListItem. At first i thought this behavior may be because i used the new EventFiringEnabled property and not the deprecated DisableEventFiring method. However that was not the case. I was able to reproduce the same behavior regardless of the two approaches.
This is contrary to what i have read (and always believed) in different blogs (for examples - http://adrianhenke.wordpress.com/2010/01/29/disable-item-events-firing-during-item-update/)
Unfortunately the MSDN documentation couldn't have been more un-helpful for this - http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.speventreceiverbase.eventfiringenabled.aspx
So in the absence of any authoritative information from Microsoft or the SharePoint team, i don't who is right. If the events are only disabled in the context of the current event receiver and they continue firing normally after this event receiver has terminated in my environment, then i believe it should behave the same in all environments. Maybe some other SharePoint experts can throw some more light on this.
Are you sure that in your case none of the other events are firing? how did you verify this?
Please "Mark as Answer" if a post has answered your question or "Vote as Helpful" if it was helpful in some way. Here's why
- Proposed as answer by Hemendra Agrawal Friday, September 28, 2012 12:57 PM
Tuesday, September 25, 2012 3:14 PM -
Hi,
From my experience DisableEventFiring firing is thread-specific as it's stated there
http://sharepoint.stackexchange.com/questions/20261/what-is-the-scope-of-disableeventfiring
I don't think it's possible to disable receivers for whole farm. Or if that happened iisreset should fix that as this is not a persisted property which SharePoint keeps in database or somewhere.
BTW: New SP2010 EventFiringEnabled just calls old DisableEventFiring()/EnableEventFiring() methods. So it is not a key
Hope that helps.
Regards,
Vladimir
MCP, MCTS, SharePoint tips blog: http://buyevich.blogspot.com- Edited by Vladimir Buyevich Tuesday, September 25, 2012 4:58 PM
Tuesday, September 25, 2012 4:57 PM -
After a week of not getting the events to fire, it's finally firing. No changes. Just started working. Nice!
Thanks all!- Edited by jd_hancock Thursday, October 4, 2012 7:12 PM
- Marked as answer by Qiao Wei Monday, October 8, 2012 9:57 AM
Thursday, October 4, 2012 7:12 PM