Business Rules were introduced as an out-of-the-box MS Dynamics CRM 2013 feature and provide CRM administrators with the ability to implement custom form logic via a simple to use designer UI. The designer UI enables non-technical individuals to implement interface driven business logic without the need for JavaScript. The end result is delivered faster and with less expense than custom script development.
Business Rules monitor the behaviour of fields on a form and define one or more actions to be performed when the conditions are met. The following are conditions that can be evaluated:
- Check a fields value against a static value
- Check a fields value against the value of another field on the same form
- String multiple conditions together separated by AND in one clause
The following defines the actions that can be performed when certain conditions are met on the form:
- Show error message
- Set field value
- Set field required or not
- Set field visibility
- Lock or unlock a field
Business rules are created for an entity:
Improvements have been made to Business Rules in MS Dynamics CRM 2015 and include:
- Rules to set default values for a field
- Support for if/else in their condition statements
- Support for and/or conditional rules
- Server side logic execution
Even with the improvements Business Rules cannot always satisfy complex business logic and administrators need to be able to identify when custom JavaScript development may be required. The following are some of the limitations of Business Rules:
- Business rules run only when the form loads and when field values change. They do not run when a record is saved, unless the scope for the rule is set at an entity level.
- Business rules work only with fields. If you need to interact with other visible elements, such as tabs and sections, within the form you need use form scripts.
- When you set a field value by using a business rule, any OnChange event handlers for that field will not run. This is to reduce the potential for a circular reference, which could lead to an infinite loop.
- 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.
- Whole Number fields that use the formats for TimeZone, Duration, or Language will not appear in the rule editor for the conditions or actions, so they cannot be used with business rules.
- You can’t add more than ten if-else conditions in a business rule.
- For Microsoft Dynamics 365 for tablets, the definition of the business rules are downloaded and cached when Dynamics 365 for tablets opens. Changes made to business rules are not applied until Dynamics 365 for tablets is closed and re-opened.
- When you set the value of a lookup field, the text of the primary field value that is set in the form will always match the text that is visible in the rule definition. If the text representing the primary field value of the record you are setting in the lookup changes, the value set by your rule will continue to use the text portion of the primary field value defined by the rule. To fix this, update the rule definition to use the current primary name field value.
- It is useful to understand that the value set for a lookup has three parts:
- Name: The text of the primary field value you see in the form.
- Id: The unique identifier for the record. This is the data that is saved. This is not visible in the form.
- LogicalName: The name of the entity, such as contact, account, or opportunity.
- The rule will set all three parts of this value. The Id value for a specific record never changes, but the Name value might change.
For example, if you define a rule to set a lookup to a contact that has the Full Name of ‘Old Name’, this text is the Name you will see in the lookup when it is set by your business rule even if someone later changes the Full Name of the contact to ‘New Name’. The lookup Id value will be correctly set to the expected record, but the Name (which is not saved) will reflect the rule definition value rather than the current Full Name value of the record it references.At the end of the day even with its limitation Business Rules are a powerful feature which enables the quick and cost effective implementation of custom form logic. And with future releases of MS Dynamics CRM we can only expect further improvements.- Business rules run only when the form loads and when field values change. They do not run when a record is saved, unless the scope for the rule is set at an entity level.
No comments:
Post a Comment