Create and Edit Business Rules & Understanding Business Rules in MS Dynamics 365
Business Rules feature in MS Dynamics 365 provides various conditional functionalities to apply form logic without writing JavaScript code or plugins. Business rules provide a simple interface to implement and maintain fast-changing and commonly used rules. They can be applied to Main and Quick Create forms, and they work in Microsoft Dynamics 365 for tablets and Dynamics 365 for Outlook (online or offline mode). Business rules which minimizes the need of complex codes, are internally converted into JavaScript by CRM and are applied to the forms.
By combining conditions and actions, you can do any of the following with business rules:
Ø Set field values
Ø Clear field values
Ø Set field requirement levels
Ø Show or hide fields
Ø Enable or disable fields
Ø Validate data and show error messages
Ø Create business recommendations based on business intelligence (Supported in 2016 update for Dynamics 365).
Scope of Business Rule:
The scope of business rule can be either “Entity”, “All Forms” or Specific form (any Main Form).
When we select the scope as “Entity”, it executes for all forms and at server side.
You cannot select multiple specific forms. If you choose All Forms, the rule will be applied to all the Main forms and the Quick Create form, as long as the form includes all the fields referenced by the rule.
Create and Edit a business rule in Dynamics 365:
How you create a business rule depends on whether you're using Dynamics 365 or Dynamics CRM. If you're using Dynamics 365, you can use a new drag-and-drop designer to create business rules.
1. Navigate to Microsoft Dynamics 365 > Settings > Solutions click on your work solution and from solution explorer Under Components, expand Entities, and then expand the entity you want.
2. Click on Business Rules. There are many other ways you can view, create, or edit business rules:
a. Solution -> Entity -> Business Rule: Click on New Icon to create new OR Open existing by clicking from the available Business Rules.
b. Solution -> Entity -> Field: When you view an entity field, you will find a Business Rules node that will show you only the business rules that include this attribute.
c. Form Editor: From the form editor, you can use the Business Rules button in the ribbon to show the Business Rules Explorer on the right side. This will show you all business rules that will be applied just for this form.
d. Form Editor -> Field -> Field Properties: When you view the properties for a field that is used in a form, you will see a Business Rules tab that shows you the business rules that include this attribute.
If an existing rule is similar to a rule you want to make, you can open that rule and use the Save As button to copy an existing rule as a starting point for a new rule.
If you want to Change/ Edit an activated business rule, you must deactivate it before you can edit it.
Set Scope: In the top right of the form, use the Scope field to set the scope for the rule.
Configure conditions: To add a condition, click the + icon and a new condition row will appear with default values set. Enter the field name to set the Field, and then choose the appropriate Operator. Operator options will change depending on the data type of the field.
Conditions are checked whenever any field referenced within the condition changes.
You can choose three different types of conditions:
Field: Use this type to compare the value of one form field with another.
Value: Use this type to compare the value of one form field with a value you enter.
Formula: This option appears only for numerical or date data types. Used for simple arithmetic calculations.
Configure actions: To add an action, choose the Add button + and you will have the following options:
- Show error message: To show any error message on a field if condition not satisfied.
- Set field value: To set any field value from another Field or typed any value OR formula.
- Set Default Value: Defaulting any filed value
- Set business required: To change the requirement level for the field to Not Business Required or Business Required.
- Set visibility: Show Field and Hide Field.
- Lock or unlock field: To Lock and Unlock a field. When the field is locked, you will not be able to edit the value in the field.
Test and activate your business rules: Before anyone can use the business rules you have created, you must validate and activate them. You can test business rules by using the Preview button in the form editor.
Below is sample to Set Business Required based on a Condition:
Limitations to Business Rule:
Business rules are intended to address common actions. Compared to what a developer can do by using form scripts, business rules have limitations. However, business rules are not intended to replace form scripts.
Here are a few limitations to using business rules:
·
Business rules run only when
the form loads and when field values change. Also they are not executed during bulk edits and
imports. They do not run when a record is
saved, unless the scope for the rule is set at an entity level.
· When you set a field value by using a business rule, any OnChange event handlers for that field will not run.
· If a business rule references a field that is not present on a form, the rule will simply not run. There will be no error message.
· You can’t add more than ten if-else conditions in a business rule.
· JavaScript method cannot be called from Business Rule.
· Business rules work only with fields. Business rule can’t interact with other visible elements, such as tabs and sections, within the form you need use form scripts.
· Expressions can be combined either using AND, or using OR, but not both.
No comments:
Post a Comment