JavaScript vs Business Rules
Dynamics 365 provides two main options for implementing client‑side logic on forms - Business Rules and JavaScript. Both can support field validation, visibility, defaulting values and enforcing simple behaviour.
This page explains when each option should be used, why it matters, and the limitations and considerations to be aware of.
When to use Business Rules
Business Rules should be the default choice for simple logic that does not require complex conditions. They are easy to configure, update and deploy, and do not require any coding skills.
Business Rules are suitable for:
- Showing or hiding fields
- Setting field values
- Clearing field values
- Validating data with simple conditions
- Locking or unlocking fields
- Applying straightforward multi‑step conditions
Why choose Business Rules
- They are easier to maintain and understand
- They are visible directly on the table and form, improving transparency
- They reduce the amount of custom code within a solution
- They work across both the web client and mobile app automatically
Key considerations
- Business Rules can become inefficient when conditions are very complex
- They are harder to debug when multiple rules overlap
- They run on the client side, so intensive logic can impact form performance
Note: If a requirement can be met cleanly using a Business Rule, it should be used before considering JavaScript.
When to use JavaScript
JavaScript should be used when the requirement is too advanced or too performance‑critical for Business Rules. JavaScript allows complete control over the client‑side experience and supports more granular, dynamic behaviour.
JavaScript is suitable for:
- Advanced form logic with complex branching
- Dynamic control over fields, tabs or sections
- Real‑time calculations or logic that must run immediately
- Interacting with the form context
- Calling APIs or running asynchronous client‑side operations
- Situations where performance is important and Business Rules become too slow or layered
Why choose JavaScript
- It provides full control over the form behaviour
- It can handle complex logic more efficiently than multiple Business Rules
- It can deliver better performance in scenarios where many Business Rules would run sequentially
Key considerations
- JavaScript must be version‑controlled, code‑reviewed and tested
- It increases long‑term maintenance overhead
- It requires developer skills
Complex Business Rules may not be efficient
While Business Rules can handle multi‑step conditions and branching logic, they are not always efficient. A complex Business Rule that tries to do too much can slow down form load times, clash with other rules, or be harder to understand and maintain.
In these cases, a small, well‑written JavaScript function can provide:
- Better performance
- Clearer logic flow
- Easier debugging
- More predictable behaviour during form events
Choosing JavaScript for these scenarios is acceptable, as long as configuration and simpler Business Rules have been considered first and ruled out.
Summary
- Use Business Rules first for simple logic on forms
- Use JavaScript when behaviour becomes complex or performance‑sensitive
- Avoid overly complex Business Rules that reduce performance when JavaScript may be more efficient
- Always choose the approach that delivers the requirement with the least complexity, while staying maintainable and aligned with DfE’s CRM standards