Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a client windows application that is uploading many rows of data to a list. However, I don't want the event handler on the list to fire while rows are being added via the windows application.

Is there a way in the Client Object Model to disable, or remove and add the list event handler?

Thanks.

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

If you create a web service as @moontear suggest you can use this solution by Adrian Henke to update items without triggering events:

public class SPListItemExtensions : SPItemEventReceiver, IDisposable
{
    private readonly bool _oldValue;

    public SPListItemExtensions()
    {
        _oldValue = EventFiringEnabled;
        EventFiringEnabled = false;
    }

    #region IDisposable Members

    public void Dispose()
    {
        EventFiringEnabled = _oldValue;
    }

    #endregion
}

Usage:

using (new SPListItemExtensions())
{
    item.Update();
}

Referenses:
http://stackoverflow.com/a/2468156
http://adrianhenke.wordpress.com/2010/01/29/disable-item-events-firing-during-item-update/

share|improve this answer
add comment

Unfortunately you will not be able to access the event receivers using the COM.

See the MSDN documentation on the SP.List object. Your only chance would be to develop some kind of custom webservice which you could call from you client code and which disables the event receiver temorarily.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.