0

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?

thomas.st
  • 393
  • 2
  • 5
  • 17

2 Answers2

1

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();
 }

}
thomas.st
  • 393
  • 2
  • 5
  • 17
Greg
  • 942
  • 10
  • 18
  • The hidden field would be a nice workaround. The HandleEventFiring would be a problem, because I don't have a project for the workflow. The workflow was made with Sharepoint Designer 2010... – thomas.st Aug 14 '13 at 08:53
  • Then the hidden field is the solution – Greg Aug 14 '13 at 08:58
0

To answer your first question:
Yes, you can find your workflow. The easiest way would be to use the SharePointManager 2010 and

  1. Navigate to your site collection is located
  2. Lists -> [Your List] -> Event Receivers
  3. Check each Event Receiver's properties and delete the event receiver that is firing twice.

I don't know if I understand your second question correctly, but here goes:
A workflow can be started manually by a user or automatically if a List Item is

  • Added
  • Updated or
  • Deleted

Other than that there is not much of a differance.

Ben McDougall
  • 251
  • 2
  • 12
  • The question is not how to find my workflow, the question is "How can i **find out** if a **workflow called** my event receiver?" – thomas.st Aug 14 '13 at 08:37
  • Example: A user edits an item and then the workflow edits the same item, because the user edited the item. (confused?!) --> so the event receiver gets called 2 times. (My workflow always starts when an item got edited) – thomas.st Aug 14 '13 at 08:44
  • Just open the List item in the browser, click on the workflow button and look into the workflow history. Should see what is happening. But you can also use the information stated in my answer to add comments or look into the workflows. – Ben McDougall Aug 14 '13 at 08:47