Dataverse & Development November 3, 2026 · 11 min read · Updated November 9, 2026 · Last reviewed November 9, 2026

Business Rules vs. JavaScript vs. Plug-ins vs. Power Automate: How to Choose

A practical guide to choosing between business rules, client-side JavaScript, plug-ins, and Power Automate in Dataverse and Dynamics 365, with a decision ladder and common mistakes.

Nordlys Consulting graphic with the headline: Rules, scripts, plug-ins, or flows

Every Dynamics 365 or Power Platform project hits the same question: where should this logic live? Pick the wrong place and you get validation that can be bypassed, flows that cannot stop a bad save, or plug-ins that make every form feel slow. This guide explains how the main options differ and gives you a short decision ladder you can apply to any requirement.

The short answer

Use the simplest tool that runs in the right place. Three questions settle most cases:

  1. Where must it run? In the browser, for instant feedback on a form, or on the server, so it applies however the data arrives?

  2. When must it run? During the save, so it can block or roll it back, or after the save?

  3. Who will maintain it? Prefer the lowest-code option that meets the requirement, and move up to code only when you need to.

Note: Microsoft’s architecture guidance draws the same line. Form script, canvas app formulas, and form-level business rules run in the user interface. Plug-ins, cloud flows, and table-scoped business rules run on the server when data is sent to it by an app, a flow, or an API call.

The four options at a glance

Option

Runs

Timing

Best for

Watch out for

Business rule

Form scope: in the browser. Table scope: on the server

Instant on the form. Synchronous on the server with table scope

Show or hide fields, make fields required, set values, simple validation on one table

Works only with columns of its own table, and the set of actions is limited

JavaScript

In the browser, on model-driven app forms

Instant, on form events

Dynamic form behavior such as filtering lookups, conditional tabs, and calling the Web API from a form

Does not run for API calls, imports, or integrations, so never rely on it for data integrity

Plug-in (C#)

On the server, in the Dataverse event pipeline

Synchronous (can block or roll back the save) or asynchronous

Validation and calculations that must always apply, and multi-table transactional logic

Sandbox time limit, developer skills and deployment required, and synchronous plug-ins add to save time

Power Automate cloud flow

On the server, outside the save

Asynchronous, after the save

Notifications, approvals, creating related rows, calling other systems

Cannot block a save, and can loop if it updates the row that triggered it

Business rules: the no-code starting point

Business rules let makers define conditions and actions without writing code. You can show or hide a column, make it required, set its value, or show an error message. The rule’s scope decides where it runs. With form scope it runs in the user interface. With table scope it runs on the server, synchronously, and applies no matter which app or integration created the data.

Start here for simple, same-row logic. The main limit is that a business rule works only with the columns of its own table. When you need data from another table, branching logic, or loops, move up to JavaScript for form behavior or a plug-in for server-side enforcement.

JavaScript: for the form experience, not for guarantees

Form script is the right tool for dynamic behavior on a model-driven form, such as filtering a lookup based on another lookup, toggling tabs, or calling the Web API while the user works. It runs only in the browser, so anything that does not use the form skips it. That includes data imports, integrations, and direct API calls.

function onCountryChange(executionContext) {
  // Always get the form context from the execution context. Xrm.Page is deprecated.
  const formContext = executionContext.getFormContext();

  const country = formContext.getAttribute("address1_country").getValue();
  const stateControl = formContext.getControl("address1_stateorprovince");

  // Cosmetic only: this changes what the user sees, not what the server accepts.
  stateControl.setVisible(country === "United States");
}

Treat client script as user-experience polish. If a rule has to hold, enforce it on the server as well.

Plug-ins: when the rule must always hold

A plug-in is a custom event handler that sits between the Dataverse API and the data. You register it against a message such as Create or Update at a stage in the pipeline: PreValidation (before the database transaction), PreOperation, or PostOperation (both inside the transaction). A PostOperation step can also be registered as asynchronous, in which case it runs outside the transaction.

Three details matter in practice:

  • Cancel early. An exception thrown at a synchronous stage rolls back the whole transaction. Microsoft’s guidance is to detect cancel conditions in PreValidation and throw an InvalidPluginExecutionException with a clear message.

  • Mind the time limit. Plug-ins running in the sandbox have a two-minute limit, after which a timeout exception is thrown. Keep synchronous work short, and move long-running work to Power Automate, Logic Apps, or Azure.

  • Don’t trigger yourself. Updating the same row a plug-in is registered on raises another Update event. Use filtering attributes and design the logic so it cannot loop.

This example rejects an end date earlier than the start date, regardless of whether the data came from a form, an import, or an API call:

using System;
using Microsoft.Xrm.Sdk;

public class ValidateDates : IPlugin
{
    public void Execute(IServiceProvider serviceProvider)
    {
        var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

        if (!context.InputParameters.Contains("Target") ||
            !(context.InputParameters["Target"] is Entity target))
        {
            return;
        }

        // On Update, Target holds only the changed columns. A production version
        // should also read unchanged values from a registered pre-image.
        var start = target.GetAttributeValue<DateTime?>("new_startdate");
        var end = target.GetAttributeValue<DateTime?>("new_enddate");

        if (start.HasValue && end.HasValue && end.Value < start.Value)
        {
            // Cancels the operation and shows this message to the user or caller.
            throw new InvalidPluginExecutionException("The end date must be on or after the start date.");
        }
    }
}

Register it on Create and Update, in the PreValidation stage, with filtering attributes on the two date columns.

Power Automate: after the save, not during it

Automated cloud flows start when a Dataverse row is created, updated, or deleted, and they run asynchronously. That makes them ideal for work that can happen after the save: sending notifications, starting approvals, creating follow-up rows, or calling other systems. It also means a flow can never stop a bad record from being saved, because the save has already happened by the time the flow runs.

Set trigger filters so a flow starts only when the relevant columns or conditions change, and avoid flows that update the very row that triggered them. For heavy integration volumes, webhooks and Azure Service Bus are alternatives to look at.

Formula columns, custom APIs, and Dataverse Functions

  • Formula columns are read-only columns whose value comes from a Power Fx formula over other columns in the same row, such as Quantity * 'Unit Price'. Use them instead of script or a plug-in for simple derived values.

  • Custom APIs let you define your own reusable server-side operation and call it from apps, flows, or code. They are a good fit when one business event touches several tables, instead of registering plug-ins on each table.

  • Dataverse Functions (formerly instant low-code plug-ins) let makers write reusable server-side logic in Power Fx. As of this writing, Microsoft’s documentation still labels them a preview feature that is not intended for production use, so check their current status before relying on them.

The decision ladder

Decision ladder with five questions: formula column, business rule or JavaScript, table-scoped business rule or synchronous plug-in, Power Automate cloud flow, and custom API.

Here is the same ladder as text. Start at the top and stop at the first yes:

  1. Is it a value derived from other columns on the same row? Use a formula column.

  2. Is it only about how the form looks or behaves? Use a business rule with form scope, or JavaScript if the rule cannot express it.

  3. Must it apply however data arrives, and be able to block the save? Use a table-scoped business rule for a simple same-table check, or a synchronous plug-in for anything more.

  4. Can it happen after the save? Use a Power Automate cloud flow.

  5. Is it a reusable server-side operation called on demand? Use a custom API.

Common scenarios and the right tool

Scenario

Use

Show a column only when another column has a certain value

Business rule (form scope)

Make a column required when a status changes

Business rule

Filter one lookup based on another lookup

JavaScript

Reject an end date earlier than the start date, even from imports and the API

Table-scoped business rule for same-table checks, or a plug-in

Total equals quantity times price

Formula column

Email the owner when an opportunity closes

Power Automate

Create several related rows together and roll everything back on failure

Synchronous plug-in

Call an external system after a record is created

Power Automate (webhooks or Azure Service Bus for high volumes)

Clean up old rows on a schedule

Scheduled flow or Azure, not a plug-in

It also depends on where the data comes from

Everything above assumes someone is working in a form. In practice the same record can arrive through a form, a grid, a canvas app, an Excel import, an integration, or a data migration, and logic that works for one of those paths can silently do nothing for another. Choose the tool by asking which paths must be covered.

Tool

Model-driven form

Grid or subgrid edit

Canvas app or Power Pages

Excel or import

API, integration, or migration

Another flow or plug-in

JavaScript (form script)

Yes

Partly, through editable grid events only

No

No

No

No

Business rule, form scope

Yes

Partly

No

No

No

No

Business rule, table scope

Yes

Yes, UI actions limited

Yes, data actions only

Yes

Yes

Yes

Plug-in (synchronous)

Yes

Yes

Yes

Yes

Yes

Yes

Cloud flow or asynchronous plug-in

Yes, after the save

Yes, after the save

Yes, after the save

Yes, after the save

Yes, after the save

Yes, after the save

Formula column

Yes

Yes

Yes

Yes

Yes

Yes

Note: Test every channel in a sandbox. Behavior can vary by tool and configuration, and privileged callers can skip custom plug-ins during bulk operations, as described below.

What this means in practice

  • Anything that must always hold belongs on the server. That means a table-scoped business rule or a plug-in. Form-only logic is a convenience, not a guarantee.

  • Pair them. Use a form business rule or script for instant feedback, with a server-side rule as the backstop.

  • Test every path, not just the form. Create and edit a row on a form, edit it in a grid, import a row that breaks the rule, create one through the API, and create one from a flow.

  • Business rules aren’t retroactive. Creating or changing one doesn’t re-run it against rows that already exist.

  • Grids are patchy. Editable grids support only some business rule actions, and editable subgrids don’t support business rules at all.

  • Business rules only see their own table. They can’t read related rows, so cross-table checks need JavaScript on the form or a plug-in on the server.

Data migrations and bulk loads

Migrations are where channel mistakes show up. Synchronous logic adds time to every row, and asynchronous logic can back up system jobs during large loads. Microsoft provides a bypass option, BypassBusinessLogicExecution with the values CustomSync and CustomAsync, that lets a privileged caller skip custom synchronous and asynchronous plug-ins and workflows.

  • System administrators hold the required privilege by default.

  • Logic shipped by Microsoft, such as Dynamics 365 Sales and Customer Service, can’t be bypassed.

  • Power Automate flows are handled separately and are not bypassed by this option.

  • Microsoft’s documentation describes the bypass in terms of plug-ins and workflows, so test whether table-scoped business rules are skipped before you plan a migration around them.

If admins need to override validation for backfills, a plug-in with an explicit, permission-controlled override gives you more control than a business rule.

What about buttons on the command bar?

Commands, the buttons formerly known as the ribbon, are different from data logic. A user clicks them, so they exist only in model-driven app screens and never enforce anything. Use them to start actions, and keep rules that must hold on the server.

What you need

Use

Update or open records using the selected rows, with a simple visibility condition

Power Fx command in the command designer

Use form context or the client API, or run complex logic

JavaScript command

A multi-step dialog or richer UI

Custom page opened from a command

Run a flow on the selected rows

A command that calls the flow through JavaScript, or a custom page

A button in the global app header, an uncommon location, or a dynamically built flyout

Classic command customization (ribbon XML or tools such as Ribbon Workbench), because the command designer doesn’t cover these

Visibility rules for modern commands are written in Power Fx. Power Fx commands also require the command component library to be shared with users, in addition to the right security role.

Sources for this section

Common mistakes

  1. Using JavaScript for data integrity. Imports, integrations, and API calls bypass it entirely.

  2. Expecting a flow to block a save. Cloud flows run after the fact. Use a table-scoped business rule or a plug-in when the save must be stopped.

  3. Doing slow work in a synchronous plug-in. The user waits, and the sandbox time limit applies.

  4. Self-triggering logic. A flow or plug-in that updates the row that triggered it can loop. Use trigger conditions and filtering attributes.

  5. Reaching for code first. Microsoft’s own developer guidance treats custom code as the exception, so start with no-code and low-code options and move up only when you need to.

Frequently asked questions

Should I use a business rule or JavaScript?

Use a business rule whenever it can express the logic. Choose JavaScript when you need things a business rule cannot do, such as filtering lookups, complex form behavior, or calling the Web API from the form.

Do business rules run when data comes in through the API or an import?

Form-scoped business rules run in the user interface, so they do not. Table-scoped business rules run on the server when data is sent to it, so they do apply to API calls and integrations.

Can Power Automate stop a record from saving?

No. Cloud flows run asynchronously after the save. To block a save, use a table-scoped business rule or a synchronous plug-in.

How long can a plug-in run?

Sandboxed plug-ins have a two-minute limit. Longer jobs belong in Power Automate, Logic Apps, or Azure.

Are Dataverse Functions ready for production?

Microsoft’s documentation currently labels them a preview feature that is not meant for production use. Check the current status before you depend on them.

Sources

If you would like a second set of eyes on where logic should live in your Dynamics 365 or Power Platform solution, get in touch.

Share on LinkedIn