Wednesday, 12 November 2014

CRM 2011 Workflow execution

As newer versions of CRM are released I find myself wondering when we might reach a point where plugin code might not be required. Between Workflows, JavaScript, and Business Rules CRM it is getting easier to customize in more and more powerful ways.

Every time I think of this though I find a "gotcha" which makes me realise plugin code will still be required for a while yet.

We had an issue where the client told us that there was a bug with auditing in CRM 2011. The problem was two different sets of audit changes were listed.

The problem ended up being not with the auditing but with the workflows. Workflows do not capture data at the time of change rather they run against the data at time of workflow execution. This is a rather obvious but interesting difference.

In our case the record needed to be recommended and then approved. We had a workflow which was created and run on "Status" change that on Approval would push data to a new entity . In a real world scenario we would presume that no one would recommend and immediately approve however there would be many cases I’m sure where a fast change such as this is completely possible.

Where a fast change like this occurs chances are that 1) the workflow has not yet been created by CRM yet or 2) the workflow has been created and not run. The issue of course is the workflow will look at the Status and see "Approved" both times it runs!

So if you have a field that is updated multiple times in quick succession I suggest having a plugin (which snapshots that data) rather than relying on a workflow.

NOTE: I haven't confirmed this in 2013 or 2015 so they might actually handle snapshots in workflows? The above talks about CRM 2011 specifically.

1 comment: