Disable Sharepoint item events firing during item update

In Sharepoint, the attached item events are fired whenever you perform an item.Update()
Ryan posted a solution to this issue, using a custom event handler that disables the events upon request.

What I dislike about the solution, is the risk of leaving the events disabled. Assume an exception occurs, the code will never reach the line where the event firing is enabled (restored) again.

I suggest a using-pattern, much like the TransactionScope class used for db transactions in the entity framework.

    class DisabledItemEventsScope : SPItemEventReceiver, IDisposable
        public DisabledItemEventsScope()

        #region IDisposable Members

        public void Dispose()


Now we can use this class together with the using syntax to create a scope within all item event firing is disabled.

                using (DisabledItemEventsScope scope = new DisabledItemEventsScope())
                    item.SystemUpdate(); // will NOT fire events
                item.SystemUpdate(); // will fire events again

This way, the event firing is enabled again as soon as the code leaves the defined scope, be it through normal operation or by exceptions.

Update 1

For SharePoint 2010, use this snippet instead:

    /// <summary>
    /// Disabled item events scope
    /// </summary>
    /// <see cref="https://adrianhenke.wordpress.com/2010/01/29/disable-item-events-firing-during-item-update/"/>
    class DisabledItemEventsScope : SPItemEventReceiver, IDisposable
        bool oldValue;

        public DisabledItemEventsScope()
            this.oldValue = base.EventFiringEnabled;
            base.EventFiringEnabled = false;

        #region IDisposable Members

        public void Dispose()
            base.EventFiringEnabled = oldValue;


26 Responses to “Disable Sharepoint item events firing during item update”

  1. 1 Azrael Palatot March 2, 2010 at 6:45 am

    Thanks!!! it works

  2. 2 Simone Ferrazzo August 4, 2010 at 10:04 am

    Great, this solution is simple and very bright, but instead of use the using-pattern is not better use a try-catch-finally? Because if code generate an exception inside the using statement, the event handler is not more enabled!

  3. 3 adrianhenke August 5, 2010 at 1:55 pm

    The “using” statement is being translated to try/catch/finally anyway. Therefore if an exception occurs within a using block, it will call the Dispose(..) method of the using-object 🙂

  4. 4 Kanchan November 15, 2010 at 4:13 pm

    i am a beginner at SP workflow and facing the same issue. I have a few fields that are updated as part of workflow, i dont want to trigger a new instance when those are updated. I understand the logic but can you show me where to update the event handler?

  5. 6 Adam Carr January 28, 2011 at 1:49 pm

    base.DisableEventFiring() & base.EnableEventFiring() have both been made obsolete in SharePoint 2010.

    Use the boolean property base.EventFiringEnabled instead.

  6. 7 Tracy March 16, 2011 at 3:49 pm

    Such a clean solution! Thanks ❤

  7. 8 sdf June 9, 2011 at 5:44 pm

    much gr8 post !!!

  8. 10 Matthew Chestnut July 5, 2012 at 5:56 pm

    This solution was a HUGE help in our battle to resolve “The sandboxed code execution request was refused because the Sandboxed Code Host Service was too busy to handle the request.”

    This particular error only occurred in some environments, not all. We opened a Microsoft support case, too, but ended up coming up with a workaround ourselves based on this method of disabling event handlers.

    Our traditional method of disabling event handlers from firing was to set “this.EventFiringEnabled = false” in, for example, the ItemUpdating event handler.

    However, we discovered in some environments, for some unknown reason, the flag would be reset to true and the event handlers would fire recursively, thereby causing the [not very helpful] “too busy to handle the request” error.

  9. 11 Robin January 23, 2013 at 9:30 am

    can we use this code in timer job?

  10. 12 Alvar Kresh August 2, 2013 at 1:04 pm

    Simple and efficient…. Thanks !

  11. 13 Joshua Orimogunje September 10, 2013 at 12:10 pm

    Add to my a little spicy to the code, you can turn it to an extension class as follows:

    public static class SPListItemExtension
    public static void UpdateDisableItemEvents(this SPListItem item)
    using (DisabledItemEventsScope scope = new DisabledItemEventsScope())

    and call it in your code as follows:

  12. 15 AR November 8, 2013 at 4:05 am

    Doesn’t seem to work in SharePoint 2013.

  13. 16 bardock October 3, 2014 at 4:31 pm

    Thank you, usefull !

  14. 17 nilsandrey September 4, 2015 at 2:21 pm

    Reblogged this on Nilsandrey's Weblog and commented:
    Complement the bellow post with a comment on it from user “Adam Carr”. As reference it claims:

    “base.DisableEventFiring() & base.EnableEventFiring() have both been made obsolete in SharePoint 2010. Use the boolean property base.EventFiringEnabled instead.”

  15. 18 Marcus Abrahamsson August 18, 2016 at 1:06 pm

    What happens if I disable events and make an update and at the same time another user makes an update that should trigger an update? Will that event not trigger or does SharePoint process all requests sequentially in which case the event would be enabled again?

  16. 19 claude October 14, 2016 at 1:43 pm

    You just saved my mental health :)++

  17. 20 Giving Kiosk November 4, 2016 at 3:43 pm

    There is definaztely a great deal to find out about this subject.
    I like all of thee points you’ve made.

  18. 21 milf December 3, 2016 at 2:05 pm

    Hello there, just became alert to your blog through Google, and found that it is truly informative.
    I’m gonna watch out for brussels. I’ll be grateful if you continue this in future.
    Lots of people will be benefited from your writing.

  19. 22 dang ky 188bet December 8, 2016 at 5:51 pm

    Thank you for any other informative web site.
    Where else could I am getting that type of information written in such a perfect way?
    I’ve a challenge that I am just now operating on,
    and I have been at the look out for such info.

  20. 23 aartivirtual May 9, 2017 at 1:45 pm

    Nice post on events. you can also go with event management in
    event management college

  1. 1 Disable Event Firing Using a Using Statement and Inheritance « Sladescross's Blog Trackback on May 8, 2011 at 4:13 pm
  2. 2 Stop SharePoint events firing | 3 Guys On SharePoint Blog Trackback on September 14, 2011 at 3:00 pm
  3. 3 Curia Damiano blog | Disabling event firing outside an event receiver Trackback on November 22, 2013 at 4:13 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: