Exploring the new features that came along with Dynamics CRM 2015 is fun indeed and what can be more fun than getting a chance to implement that in real time project. While going through the new features sometimes we tend to miss out on the small nuances that would actually make the new stuff to work as you like. And this is what exactly happened with my colleague.
So this is what he did. He had a workflow which when fired would create a contact. In the contact, he defined a business rule that would throw an error message if a particular business condition satisfied. For those who have not yet explored the new Business Rules feature of Dynamics CRM 2015 – With 2015 you can enable your business rules to fire from the server side also.
So my colleague was just joyous thinking about the fact that he no longer needed to write a plugin to do this stuff. Few clicks here and there and the job is done. However strangely enough even when the condition satisfied, there was no error and the workflow created the contact record.
So what went wrong here. Let’s see. For the blog since I could not present the actual situation of my client project, I would be just mocking up the scenario.
Let’s say we create a business rule which would throw an error message if the first name begins with D. No biasedness against people whose names start with D. Even mine starts with D
Let’s see how the business rule looks like
Pretty simple. Isn’t it. Then I go ahead and activate it.
I have created a on-demand workflow which would create a contact with first name starting with D. Strangely enough when I run the workflow, the workflow is getting executed successfully and the contact is also getting created. So did my business rule not fire?
Time to get dirty. So let’s check our business rule again. When you create a business rule for an entity from form customization, the scope of it defaults to the default form for the entity.
To make the business rule fire on the server, you have to change it to the Entity. After I change it to entity and activate it and run the workflow again, I get the error and the contact is not created.
A small stuff but strangely enough many people forget while designing the business rules. Hence thought of sharing in case someone finds it useful.