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 (16)

  1. Catherine says:

    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 😀

    Catherine Eibner

    http://blog.cybner.com.au

  2. Anne Stanton says:

    Nice job! Thanks for sharing.

    Cheers The CRM Lady

    Anne Stanton

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

  4. Deciding when to use a workflow vs. a plug-in is usually a straight forward process. In general, I always

  5. Deciding when to use a workflow vs. a plug-in is usually a straight forward process. In general, I always

  6. Deciding when to use a workflow vs. a plug-in is usually a straight forward process. In general, I always

  7. Barry Givens says:

    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.

  8. humlezg says:

    Barry,

    You can also create custom workflow assemblies to query external systems, so workflow would still be an option.

  9. Vijay Jaiswal says:

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

  10. humlezg says:

    Vinjay,

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

  11. Ramble On says:

    Initiating K2 blackpearl Processes In this first chapter of our series on integrating K2 blackpearl and

  12. rk says:

    what may be the difference between an asynchrounous plug in and a workflow?

  13. humlezg says:

    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.

  14. pablop says:

    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.

  15. pablop says:

    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

  16. Marcos says:

    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