In our last post we discussed business rules and in this post we are going to show how we can create business rule in MS CRM 2013. To create business rule navigating to entity customization. Let’s take a very simple example we want to validate if Relationship type is selected a “Consultant” we need to make industry field business required in account entity. If we need to implement this in JS code we need logic like below
if Relationship type value is consultant then
make Industry field required
Remove required from Industry field
In the same way we need to create two business rules for this, one to handle if part and other to handle else part, so let’s design our business rule for this.
- Navigate to account entity customization and select business rule from left navigation.
- Provide label “Make Industry required”
- Add a condition using below settings:
Field: Relationship Type
- Click on “Check Mark” to collapse condition section.
- Add action using below settings
Status: Business Required
- Click on “Check Mark” to collapse action section.
- Set scope for your business rule.
- Save and close business rule.
- Activate your business rule.
Let’s test our business rule navigate to Account entity and create new account and set Relationship type as “Consultant” it will make industry field required like below:
But if you will select some other value in Relationship type it will still keep industry field required like below:
To handle this we need to create another business rule to remove business required in case relationship value is different than consultant. Create new business rule using below configuration:
Activate your second business rule and open account record. Now when you will select some other value it will remove business required from industry field.