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.
Discover more from Debajit's Power Apps & Dynamics 365 Blog
Subscribe to get the latest posts sent to your email.
i’m having a similar issue when creating a business rule (using entity) – when i execute a workflow to change the status reason (for example), and have a business rule (that runs on the server) that busienss rule doesnt fire once the workflow does its thing? Running Xrm.Page.data.entity.save() in js does not trigger business rules according to official docs – Do you know a clever work around?
The only work around i had was to refresh the entire form using window.reload() or using: Xrm.Utility.openEntityForm… but I dont like page refreshes, would rather have somethign a bit more unobtrusive
Hi,
Thanks for reading my blog post.
Can I have a little more information here.
What are the condition of the business rule to fire. And is the workflow synchronous or asynchronous?
Hi,
What if I want my business rules to run both client side and service side. What configuration do I need to do to achieve this.
Thanks
Hi Bipin,
When the scope is Entity, it works server side and client side as well.