Share via


Plug-in or Workflow?

With the CRM 4.0 enhancements to the plug-in and workflow engine as well as the introduction of the web based workflow designer I've seen many CRM developers asking the same question: When should I use workflow vs. plug-ins? The answer is “depends”; the right approach is determined by the characteristics of the task that you are trying to accomplish. The following matrix gives you my take on this:

Requirement

Plug-in

Workflow

Needs a synchronous action to happen before or after an event occurs

x

The same piece of logic will be executed for different events and possibly on different entities

x

x

The logic needs to be executed while offline

x

Needs elevation of privileges (impersonation)

x

Needs to execute on events other than assign, create, update, setstate

x

The process/logic may take a long time to complete or will be a persistent process (multiple long running steps)

x

Needs an asynchronous action

x

x

End users will need to modify the process logic

x

Child sub processes will be triggered

x

It may also be the case that a combination of both approaches is required; a plug-in can trigger a workflow and a vice versa. From the above matrix the most decisive factor is whether you need a synchronous action or not; if you do, plug-ins are the way to go, if you don’t then other factors need to be pondered.

Comments

  • Anonymous
    April 13, 2008
    I was looking for a matrix that defined the decisions behind when to choose a plugin over a workflow well - this is perfect! Thank you :D Catherine Eibner http://blog.cybner.com.au

  • Anonymous
    April 21, 2008
    Nice job! Thanks for sharing. Cheers The CRM Lady Anne Stanton

  • Anonymous
    June 03, 2008
    I've added a similar comparison between workflows and plugins on my blog, including consideration of custom workflow activities. This can be found here: http://mscrmuk.blogspot.com/2008/06/differences-between-workflow-and.html

  • Anonymous
    June 27, 2008
    Deciding when to use a workflow vs. a plug-in is usually a straight forward process. In general, I always

  • Anonymous
    June 27, 2008
    Deciding when to use a workflow vs. a plug-in is usually a straight forward process. In general, I always

  • Anonymous
    June 27, 2008
    Deciding when to use a workflow vs. a plug-in is usually a straight forward process. In general, I always

  • Anonymous
    June 30, 2008
    One other requirement that might be added is "The logic needs to query CRM or another system" that is, any time the action needs to find another record or records and take some action on them a plug-in is needed.

  • Anonymous
    July 01, 2008
    Barry, You can also create custom workflow assemblies to query external systems, so workflow would still be an option.

  • Anonymous
    September 01, 2008
    I need to know, is it possible to modify business functionality logic of CRM 4.0 with Plug-ins / Work flow.

  • Anonymous
    September 01, 2008
    Vinjay, That is the whole point :).   Yes, i ngeneral, you can modify or construct new business logic using plug-ins or workflows.

  • Anonymous
    February 04, 2009
    Initiating K2 blackpearl Processes In this first chapter of our series on integrating K2 blackpearl and

  • Anonymous
    June 23, 2009
    what may be the difference between an asynchrounous plug in and a workflow?

  • Anonymous
    June 30, 2009
    rk: Workflows are meant to orchestrate a "long" running process that consists of several steps.  Plug-ins are meant for more granular operations.   Let me give you an example... assume that after updating an account you want to synch data to another system by contacting a webservice. You probably don't want to do this synchronously as the connection to the service may fail, you may need to retry, etc.  So you go with the asynch approach.  Now what to do? plug-in or workflow?  Since you will likely be performing a very granular (kind of one step) operation you are probably good with a plug-in.   In contrast, what if you need to run, lets say a "follow-up" process that not only needs to runch asynch but also has multiple conditions and/or branches and wait conditions (e.g. you may need to wait until some other condition is met)... then you are definitively better off with a workflow; otherwise you will likely find yourself building a mini-workflow engine inside a plug-in... you will notice this if you end up having multiple if/switch statements all over your plug-in code just to control the branching logic instead of actual business logic.

  • Anonymous
    May 30, 2010
    I suggest you ckeck this out for additional information: weblogs.asp.net/.../plugins-vs-workflows-in-dynamics-crm.aspx it mentions other scenarios when to choose one or another and also talks about security contexts on both cases. Hope it helps. PP.

  • Anonymous
    June 25, 2010
    Additional info to help to clarify this dilemma and make better decisions (it includes security aspects)... blogs.msdn.com/.../plug-ins-vs-workflows-in-microsoft-dynamics-crm.aspx

  • Anonymous
    November 22, 2011
    Humberto, may you help me in order to do error control (manage Exceptions) inside of workflow, ie: if I have an step (that update some properties) inside of workflow, and need to detect some SQL errors (like timeout or generic SQL errors). Do you known how can I do that (for example, if occurs timeout error I would like to retry) ... I appreciate your help. I'm using MSCRM 4 Regard Marcos