Earlier I demonstrated the new capabilities that Microsoft Dynamics CRM 2013 has introduced for workflow processes: showing error messages with real-time workflows. I covered examples of record assignment, merging duplicate accounts and stopping unwanted updates in the Mobile Express client. This time I’ll take a look at how the error message feature can be leveraged in managing the sales process on opportunity records.
The new Business Process Flows in CRM 2013 provide the possibility of setting fields in a stage as required. This is a nice advancement over the previous platform functionality that only allowed you to set fields as business required per entity, since now we can dynamically control the stage at which we will require the user to input the information onto a form. It’s very typical that a user wouldn’t yet have much details available about a sales opportunity when first entering the information into the CRM system, so it makes total sense to not ask too many questions initially. After all, you can make a field required, but if the user simply doesn’t possess the information asked in it, he or she may just enter dummy data into the field to meet the technical minimum requirements.

Looking at the default opportunity sales process that comes with Dynamics CRM, we have a number of bit fields in the Close stage that indicate tasks the opportunity owner should complete before closing the opportunity. In the Business Process Flow editor we can tick a box and set these fields to be required. What does a required field in the Business Process Flow then mean exactly? It simply means that you can’t move the record forward from that stage until a value is entered in the field. In the case of bit fields (two options) the value should be set to Yes (ID 1) to meet the criteria.
OK, sounds logical, but what about if we’re already in the last stage of the process? How is the requirement level enforced if there are no more stages to move to? The answer is: it’s not. Since the actual closure of an opportunity as Won or Lost is not a stage in the process but rather a change of the record status, Business Process Flow has nothing to do with it. We can observe this behavior by setting a field required in a process stage and then navigating to a test opportunity and attempting to close it as Won. In our example, the File Debrief field has been set as required in the Opportunity Sales Process, but the system still allows the user to close the opportunity without entering data into this field.

“That sounds like an unfortunate gap in the business logic, I guess we’ll need to get a developer to write a plug-in for us to stop the status change operation if required data is missing.” Hold it right there, mister! We’re dealing with Dynamics CRM 2013 here, which means we can build the equivalent feature with a real-time workflow process! No custom code needed for such a simple task, as long as you know how to leverage the new interactive nature of synchronous workflows.
Let’s create a new workflow on the opportunity record and set it to start when the record status changes. We’ll configure it to be run as “after” the event, since we’re interested in capturing the new status value of the record. In the workflow criteria we’ll define that we want our business logic to apply if the opportunity is being set as Won but the File Debrief field has not bee set to Completed. Since this is a real-time workflow, we can add a step where we set the process to be stopped as Cancelled and then define an error message in that step’s properties. This will then be presented to the end user who is triggering the status change event if the workflow criteria is met.

Now, let’s go to our test opportunity, re-open it and attempt to close it without marking the File Debrief field as Completed. When clicking the Close as Won button on the opportunity form command bar we’re presented with the standard, non-customizable Close Opportunity dialog window asking us about the Actual Revenue, Close Date and so on. Since we’re so excited about having won the opportunity we’ve completely forgotten that there were still tasks we needed to complete before we’re allowed to close it off from the sales pipeline.

Once we click OK, a new dialog window is presented: the Business Process Error prompt, along with the error message that we defined in the Stop stage of our workflow process. The opportunity close event is rolled back and we can return to the opportunity form to see what steps of the process we had neglected.

As I mentioned in my previous article about the new business process automation capabilities of CRM 2013, Business Process Flows are essentially a process map that is meant to guide the user through the stages. It cannot actually perform any automated tasks by itself, nor enforce any rules apart from the changing of the stage through the visual business process control at the top of the form. To implement this type of functionality you should look into Business Rules and Real-Time Workflows instead.



Leave a Reply