Thursday, March 24, 2011

Event Receivers vs Workflows

Students frequently ask about the differences between Event Receivers and Workflows in SharePoint. After all, there’s plenty of overlap between the two technologies – they both execute some form of code in response to the user performing an operation. However, they are different, and designed for different goals. Here’s a quick overview of the differences.

Event Receivers Workflows
Can execute either before or after the operation Always executes after the operation
Can cancel the operation Cannot cancel the operation as the item will have already been created
Cannot be launched manually by the user Can be started manually by the user
Not designed for user interaction Specifically designed for user interaction
Can execute in response to many different actions, including deletes Can only execute in response to one of four events – Manual, an item being created, an item being edited, and an item being submitted for approval
Must be created in Visual Studio Can be created with Visual Studio, Visio or SharePoint Designer

The main key when choosing between a workflow and an event receiver is the need for a UI. If user interaction is required to process an item a workflow is almost always going to be your best choice. If you need to respond to an event other than the four allowed for by a workflow, or the operation is completely automated, then an event receiver is the best option.

That said, I have occasionally created an “event receiver” by using a workflow from SharePoint designer. If you’re looking for something simple, then keep the solution simple.

Let the above table, your experience, and the needs of your users guide that decision. And always – Keep It Simple!

6 comments:

  1. excellant information... thanks

    vamsi

    ReplyDelete
  2. And another important to choose for workflows if the logic needs to be maintained "often" or by a (super) user

    ReplyDelete
    Replies
    1. Absolutely. Workflows provide a much better UI out of the box for modifying how it's going to behave.

      Delete
  3. Thanks a lot for this information

    ReplyDelete
  4. Any performance comparison on large list?

    ReplyDelete