What are Business Rules?
Business Rules can be configured using the interface and in the backend Dynamics CRM automatically generates the client-script to perform the configured actions. The automatically generated code is not available to the users so from a user’s perspective it only involves configurations.
Capabilities of Business Rules
As mentioned above, the business rules are used to perform actions on the client-side only. The actions that can be performed are listed below.
|Show error message||This action displays an error message if the specified condition is not met. For example, if the data entered in a field does not meet certain validation criteria then the Business Rule can be configured to display an error message to the user and restrict them from saving invalid data in CRM.|
|Set field value||This action is used to set a field’s value based on a condition. For example, if the Country is selected as “Canada” then the country’s dialling code would be auto-populated; or if a field’s data needs to be blanked out because of a specific condition.|
|Set business required||This action is used to change the requirement level of a field dynamically based on a condition. In other words, by consuming this action the mandatory field can be marked as non-mandatory and vice versa.|
|Set visibility||This action is used to hide and show fields on entity forms. This action enables power users or customizers to change the visibility of the fields dynamically based on a specified condition.|
|Lock or unlock field||This action is used to lock or unlock (enable or disable) fields dynamically. Unlocked or Enabled fields are editable and Locked and Disabled fields are read-only.|
Microsoft Dynamics CRM 2013 has following three fields on the Account entity form:
- Shipping Method
- Freight Terms
Consider a business scenario where there is a requirement to hide/show “Shipping Method” and “Freight Terms” fields based on the “Industry” the Account belongs to.
The requirement is to:
- Hide Shipping Method and Freight Terms if the Industry is set to “Consulting”
- Show Shipping Method and Freight Terms if the Industry is not set to “Consulting”
Step-by-step guide to creating Business Rules
Step 1: Click on “Settings”
Step 2: Click “Customizations” -> “Customize the System”
Step 3: Click Account -> Business Rules -> New to create a new Business Rule, as shown in the figure below.
Step 4: Specify the name for the new Business Rule
Step 5: Create a new condition – if Industry is set to “Consulting”
Step 6: Now click the plus sign (+) to add an Action
Step 7: Select the action “Set Visibility”
Step 8: Set the Actions to hide “Address 1: Shipping Method” and “Address 1: Freight Terms”
Step 9: Save the Business Rule
Step 10: Activate the Business Rule
Step 11: Create a new Business Rule to show fields
Step 12: Create a condition as shown below – where industry is NOT EQUAL to Consulting
Step 13: Select “Set visibility” action
Step 14: Create actions as shown below
Step 15: Click “Save” to save the newly created Business Rule
Step 16: Activate the Business Rule
Step 17: Publish All Customizations
Step 18: Verify the newly configured Business Rule
Congratulations, you have now created Business Rules in Dynamics CRM!