Real Time Workflow and Plugin, Which One is Executed First?

Last weekend when I was preparing my presentation slide for the upcoming Dynamics CRM User Group regarding some gotchas in plugin development and with a short discussion regarding Real Time Workflow, there is a question in mind: If there is a Plugin and Real Time Workflow that registered on the same event, for example on update of field A on Contact entity, which one that triggered first? I’ve tried to find Microsoft’s documentation and could not find it, so in case anyone could point out the article/documentation, please let me know.

So to answer my own question, I setup a simple Real Time Workflow to update ‘jobtitle’ field to ‘Workflow’ on Contact entity every time I change the first name. And a plugin to update ‘jobtitle’ field to ‘Plugin’ on Contact entity every time I change the first name. To test this method, I did a bulk edit on contact record to change all their first name. And the result is… Plugins are executed first, then the Real Time Workflow. This is a conclusion of the test, as all of the records that I just bulk-edited has the value of Workflow, which mean the value specified will be the one that executed later.

Workflow

I hope this help us in designing the solution with multiple event-based processes. And to manage these execution order there’s a plugin for the famous XrmToolbox here: http://mscrmtools.blogspot.com.au/2014/04/new-xrmtoolbox-plugin-synchronous.html

Note: I personally would prefer not to mix Plugin and Real Time Workflow together to avoid confusion by putting the custom process that handled by the plugin to custom workflow activity and execute that custom workflow activity within the Real Time Workflow. However, there might be a case where the solutions are developed by multiple vendors and this kind of scenario could happened.

 

 

Advertisements

3 thoughts on “Real Time Workflow and Plugin, Which One is Executed First?

    • Thanks Ben, in case you could find the official documentation for this. Please let me know 🙂

      I might put the gotchas on next post. It’s a quite common issues for developers around infinite loop, field filtering and order of execution. The order of execution was the reason why I did this experiment.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s