I came across a new thing about Business Rules in CRM 2015 which I was not aware of. While working on JavaScript to hide a section OnChange of a field, I ran into an issue where the section was not getting hidden on change of field value. After few minutes of debug and then bit research, found that JavaScript runs before business rules. In my case, below was the scenario which caused the trouble:
I had two sections, A and B. One field “Record Type” from section “A” had Business Rule on it which hides a field “Field 1” which is in Section B. Then I had a JavaScript which triggers OnChange of “Record Type” field and hides “Section B”. As JavaScript triggers before Business Rule, JavaScript use to hide “Section B” after which Business Rule used to show the complete “Section B” again and hide only “Field 1” mentioned in business rule.
Below are few more things one should know about Business Rules in CRM 2015:
• The rules need to be activated before they take effect (similar to workflows).
• You can specify whether the rule applies to all forms or specific forms.
• The rules fire in the new mobile client for iPad and Windows 8.
• The rules are client-side rules, they do not fire during API calls, data import, etc. Microsoft’s vision is to add that support in a future release.
• The rules do not support show/hide of Tabs and Sections. You either need to mention each field individually in your Business Rule or use JavaScript.
• If your rule hides a field then CRM moves fields up to close the gap.
• You need to consider the inverse of your rule i.e. in my example I tell CRM what to do when the Est. Revenue field contains data. I don’t tell it what to do when the Est. Revenue does not contain data. I need to write a second Business Rule for that.
• JavaScript runs before Business Rules.
• String comparisons are case sensitive.