The following are some of the key components of a business rule:
- Scope: The scope of a business rule defines the execution context of a business rule. It can acquire the following values:
- Entity: Business rules will be executed in all entity operations, including the server-side events happening on the entity
- All forms: Business rules will be executed on all the entity forms. However, the rules will not apply to server-side execution
- Specific forms: Business rules will only be executed on specific chosen forms while setting up a business rule
- Condition: Condition refers to the criteria or the requisite state evaluated before a business rule action is executed. The conditions basically refer to the state of the entity and its attributes. For example, you may write a business rule that refers to a condition that checks the values on a created field.
- Action: Action refers to the process that will be executed by the business rule once the condition governing it is met. The following actions can be executed by the business rule:
- Lock /Unlock field: This action makes a field read-only or editable.
- Show error message: This action shows an error message on the Dynamics CRM UI screen.
- Set Field Value: This action sets a value in any field on the entity.
- Set default value: This action sets a default value in any field during form load. The Set Field Value action is similar to Set Default Value and only differs in usage. Using a default value, we can set a value on form load. If we don't want the field to acquire a value during form load, we can use the Set Field Value action instead.
- Set business required: This action changes the field requirement for any attribute. In Dynamics CRM, the requirement options are as follows:
- Options
- Business recommended
- Business required
- Set visibility: The action basically hides and shows any field on the entity form.
- Recommendation: This is a new action that has been introduced in Microsoft Dynamics 365. We will explain the usage of the action in the coming scenarios.