In my last blog post, The Real Power of Real Time Workflows in Microsoft CRM 2013 – Part 1, I highlighted how real time workflows could be used to enable rapid data entry. In Part 2, I’m going to review how this powerful tool can be used to enforce complex data validation rules.
Real World Scenario
The best way to describe this is through a real world example. Company A is using the Task activity entity to keep track of their employees time spent on Cases. They have created a Time Category field that will allow their employee’s to track the specific category of time being entered by the employee – they fall into three categories: On-Site, Off-Site or Support. However, they are looking to implement a business rule that enforces a minimum time value for On-Site cases, which ensures that it is never less than the total travel time required – this is a variable value that gets stored on the Account record – a completely different entity!
How It Works
Below, take a look at the Travel Duration field on the Account record – and the Time Category and Duration field on the Task activity record.
Defining The Workflow
To enforce this rule, I start by building a workflow against the Task entity. Since I want this rule to be enforced when the user tries to close the activity, I set the triggers to both On Create, as well as on Status Change. I also need to make sure that the workflow is set to Real Time. And then, I add the necessary conditions to ensure that we only throw an error when the:
- The status is set to completed
- The Time Category is set to On Site
- The Duration of the Activity is less than the Travel Time stored on the Account
And finally, the magic comes in the final step – under my condition, I add a Stop Workflow action and set the Status to Canceled. By clicking Set Properties, I can deliver a specific error message to the user, communicating exactly what went wrong with their time entry. I can even dynamically reference data form the Account record to let them know what the specific minimum for the Account they’re working with is!
See It In Action
Now, let’s take a look at what happens when I enter a Task with a Duration less than the Travel Time for MIBAR.net.
Beautiful – it works just as we expected. When I try to complete my Task with a Duration less than the Travel Time on the Account, CRM stops me – and also provides me with a detailed explanation for how to correct my issue. With some creativity, this can be extended to accommodate numerous scenarios across your business. There you have it – cross entity data validation without a line of code!
If you have any questions – or would like to discuss ways that you can improve the way you’re currently using Microsoft CRM, please feel free to schedule a free consultation with one of our CRM experts!