I just came across this post from the very educating Arvind’s CRM Blog. In this post he makes another attempt to tackle one of the most asked question by Microsoft CRM developers since the beginning of time. Should I use workflow, or plugin?
While Arvind gives a good review from a technical point of view, I think that something is missing. In fact, I think it is also missing from the other 64493 rounds of the same discussion, so it is time to say it loud and clear. Repeat after me: I will not use workflows for business logic unless I have no choice. Again: I will NOT use workflows for business logic unless I have no choice. You at the back – louder, I can’t hear you – I WILL NOT USE WORKFLOWS FOR BUSINESS LOGIC UNLESS I HAVE NO CHOICE.
Workflows are powerful end points for power users and sys admins to accomplish their tasks, and that is where it should end. Power users and sys admins are not developers. As a developer, you probably want to:
- Encapsulate your business logic.
- Have your code live happily inside a source control.
- Write unit tests for your code.
- Write integration tests for your code.
- Make sure you have control on your code.
- Make sure you can control when your code is executed, and throw an exception when someone is executing in a way you think is not good.
None of these can be accomplished by using workflows.
Therefore, if you have some business logic you need done, even if it is as simple as turning on a bit flag, use plugins!