When we advise clients on best practices regarding the use of JavaScript versus Business Rules in Model-Driven Apps, we promote the use of BRs for simple client-side logic and JS for more complex real-time logic.

Below are some common scenarios for the use of JavaScript.

SCENARIOPURPOSE
UI ManipulationShow/hide tabs, sections, or controls in real-time
Cross-entity data accessJavaScript can fetch related records whereas Business Rules are limited to the current record.
Example use cases:
– Lookup field pre-filtering based on related table query results
– Checking the current user’s security roles to adjust the form accordingly
– Querying related tables to display a custom alert banner
Complex conditional logicJavaScript can handle nested conditions, loops, and multi-field dependencies

Microsoft Documentation

Thanks to my colleague, solution architect Elise Xavier, for her contributions to this content.


Discover more from The Low-Code Logbook

Subscribe to get the latest posts sent to your email.

Posted in , , ,

2 responses to “Business Rules vs. JavaScript”

  1. Matt Parks Avatar
    Matt Parks

    I would also add a few other points:

    1. If you have a large number of business rules on a form, they can easily start to step on each other and JavaScript can be easier to debug.
    2. It is better to not use both on the same form. Looking at the JavaScript and trying to understand why something is happening only to find out a Business Rule is to blame. This might mean redoing a BR into the JavaScript, but the time it will save later is worth it.

    Like

    1. Jenny Cuevas Avatar

      Good point, Matt! I certainly agree. This has happened to me before, where I just had too much of both. We had to deprecate the BRs and convert them all to JS.

      Thanks for your input.

      Like

Leave a reply to Matt Parks Cancel reply