Search code examples
sharepoint-2010sharepoint-workflowevent-receiver

Sharepoint 2010 event receiver ItemUpdated fires twice


I attach three events to my CustomLists:

  • ItemAdded
  • ItemUpdated
  • ItemDeleting

On one list I have a workflow, which is changing columns in that list. So when I edit an entry in that list, the ItemUpdated-Event fires two times. On the other lists (without any workflows) my receiver is working fine.

How can I find out if a workflow called my event receiver?

Is there a difference between a workflow which fires the event, or a user who fires the event?


Solution

  • You can add hidden field to the list which is always sets by workflow (and only by workflow). Then you will see if workflow called the event receiver.

    Or

    You can create HandleEventFiring class in your workflow project and use DisableAllEventFiring and EnableAllEventFiring before and after updates in workflow

    public class HandleEventFiring : SPItemEventReceiver
    {
    
      public void DisableAllEventFiring()
      {
       this.DisableEventFiring();
      }
    
     public void EnableAllEventFiring()
     {
      this.EnableEventFiring();
     }
    
    }