0

I'm using an ItemUpdating event with a Document Library to run a Task generation procedure. After stepping through, it's causing issues when I check out the document which I'm forced to do after adding versioning.

There are Two calls that come almost at the same time repeating every statement/conditional so when I check out the document I run into issues.

Is there a way to delay the event handler from triggering so that one call is made while the others are queued? Or is there a way to delay the second call of an event handler within the code?

Let me know if you need any more information.

3

Before modifying item, you should Disable event firing

this.DisableEventFiring();

After finish updating you can Enable it using

this.EnableEventFiring();

Identify if event is fired as part of Check-in

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.
}

Review if event receiver is registered multiple times

  1. Create a console application and review event receivers

    using (SPSite sps = new SPSite(SiteName))
    {
        using (SPWeb spw = sps.OpenWeb())
        {
            SPList splist = spw.Lists[ListName];
            foreach (SPEventReceiverDefinition sprd in splist.EventReceivers)
            {
                Console.WriteLine(sprd.Class + " " + sprd.Name);
            }
        }
    }
    
  • when using disableeventfiring() it states that the method is obsolete, use eventfiringenabled. – matt Apr 21 '15 at 12:19
  • Yes you can use this.EventFiringEnabled = false; and then this.EventFiringEnabled = true;. – Amal Hashim Apr 21 '15 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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