Business rules in Microsoft Dynamics CRM 2013
Microsoft Dynamics CRM 2013 has been released a little time ago with a lot of new features and changes.
Business rules are one of the new features in CRM 2013. Business rules are relatively easy, well, business rules, that you can create through the user interface. Let's say you want to show or hide a certain field depending on another field's value. That would have take some javascript coding with CRM 2011 but with CRM 2013 you can actually achieve this by using only UI. So no programming needed, which is of course always welcome - especially for programmers.
So what can you do with business rules? Below lies a short list of different possibilities
- Show error message
- Set field value
- Set business required
- Set visibility
- Lock or unlock field
So very basic but indeed very helpful stuff. Let's take a look at how to actually implement a business rule.
Show or hide a field using business rules
Example:
I have created an xRM system which I use to keep track of my sport activities. I have created a custom entity type named "Sport activity". In the sport activity form I have a drop down list of different sport activity types (including running, cycling, badminton, football). I also have a "Distance" field in the form (hidden by default) and I want to show it only when I've selected a certain sport activity type (such as running or cycling).
So what I need to do is to create a new business rule that'll set distance field visible when the sport activity type equals running or cycling. I can start this by opening a form designer and double clicking the sport activity type -field. There I see Business Rules tab with the "New" button. Refer the picture below.
Click "New" and fill the form. My business rule looks like this
Notice the Scope option on a top right hand side corner. It means that this business rule applies for Information form by default. You can change the value to be "All forms" for example or if you've created a custom form you can set it as a scope.
When you're ready simply Activate your business rule and you're on the go.
Note that you have to create another business rule to hide the distance field in relevant cases. Otherwise it would never go away after the first time it is set visible.