Model-driven App Development — Part 3 of 5. Business rules provide declarative form and data logic, while JavaScript supports more complex client interactions. Choosing the simplest mechanism improves maintainability.
What you will learn
Use a business rule for straightforward visibility, requirement, default-value and validation logic that fits its scope. Use JavaScript when the interaction requires calculations, multiple related controls or custom asynchronous behaviour. Put cross-client validation in plug-ins or other server-side logic, because imports and API calls do not execute form scripts.
Implementation approach
Begin with a small, testable scope. Record the requirement, identify the Dataverse or platform component involved, and make the change in a development environment. Use solution-aware components and keep environment-specific values outside the implementation. Review the result with a second developer before promoting it.
Practical example
// Example development checklist
// 1. Confirm the requirement and owning component
// 2. Implement in a development environment
// 3. Validate permissions, null values and failure paths
// 4. Record configuration and dependencies
// 5. Promote through a controlled test deployment
Common mistakes to avoid
Do not duplicate the same rule in multiple places without defining which layer is authoritative. A client-only rule can be bypassed by integrations.
Testing checklist
Test the rule from the model-driven app, Web API and import paths. Confirm that server-side validation protects the business invariant.
Model-driven App Development: All 5 Parts
- Part 1 of 5: Model-driven App Forms — Design, Configure and Validate
- Part 2 of 5: Model-driven Form JavaScript — Events, Execution Context and Safe Patterns
- Part 3 of 5: Business Rules vs JavaScript — Choose the Right Form Logic (current)
- Part 4 of 5: Command Bar Customization — Add Actions with Power Fx or JavaScript
- Part 5 of 5: Views, Charts and Dashboards — Build Useful Model-driven Workspaces
Continue with the next part in this series to build on these concepts. Validate each step in a non-production environment before applying it to a live workload.