MSBA-272 · Lesson 9 of 12 · 19 min

Low-code plug-ins

▶ Video coming soon A video version of this lesson is on the way.

Maribeth had watched three weeks of C# with interest and some envy. She wrote Power Fx every day in canvas apps, and she asked whether there was a way for someone like her to put a server-side rule into Dataverse without learning Visual Studio, plug-in packages and PRT. There is, in preview: low-code plug-ins, which run Power Fx inside Dataverse, and the newer functions in Dataverse, also written in Power Fx. Signe agreed to spend a session on them, on the condition that they ended it with a clear rule about when Lumenvale would use them and when it would not.

What low-code plug-ins are

A low-code plug-in is server-side logic written in Power Fx and stored in Dataverse. It is created in the maker experience rather than in Visual Studio, needs no compiled assembly, and is registered without PRT. Under the covers, Dataverse runs it in the event pipeline like other plug-ins, so a low-code plug-in on a table runs whatever app, flow or integration changes the data.

Microsoft documents two kinds. Automated low-code plug-ins run when a row in a chosen table is created, updated or deleted, much like a step on a C# plug-in. Instant low-code plug-ins were designed to be called on demand from apps and flows, like a custom API. Low-code plug-ins depend on the Dataverse accelerator, a Microsoft app that Microsoft has installed automatically in new environments since October 2023; older environments may need it installed from the admin center or AppSource.

Both kinds are still in preview. Microsoft's documentation states that instant low-code plug-ins have been deprioritized and are not being delivered as a feature; they are replaced by functions in Dataverse. Automated low-code plug-ins remain in preview. Signe read the statement aloud, because it decided half the session: nobody at Lumenvale would build an instant low-code plug-in, and anything that needed on-demand Power Fx logic would be a function or a custom API.

Server-side logic options, from Microsoft's documentation at the time of the session.
OptionLanguageRuns whenStatus at the time of the session
Automated low-code plug-inPower FxA row in a table is created, updated or deletedPreview
Instant low-code plug-inPower FxCalled from an app or flowPreview; deprioritized and replaced by functions
Function in DataversePower FxCalled from a canvas app, custom page or flowPreview
C# plug-inC#A registered step on any messageGenerally available
Custom APIC# plug-in as main operationCalled as a message from any clientGenerally available

An automated low-code plug-in

To make the comparison concrete, Signe chose a rule that already existed as C#. The prototype BlockSafetyCloseWithoutPhoto, from MSBA-270, stopped a facilities work order marked as safety-related from being closed without a completion photo. In C# it was a PreOperation step on Update of lcc_workorder, filtered on the status column, with a pre-image. Maribeth rebuilt it as an automated low-code plug-in in Wiremu's developer environment, using the Dataverse accelerator app.

She chose the Work Order table, the Updated event, and the option to run before the change is saved, so the rule could stop the update. Then she wrote the expression in the formula editor, which offered the columns of the table through ThisRecord.

An automated low-code plug-in that blocks closing a safety work order without a photo. Column and choice names are illustrative.
If(
    ThisRecord.Status = 'Status (Work Orders)'.Closed
        && ThisRecord.'Safety related'
        && IsBlank(ThisRecord.'Completion photo'),
    Error({
        Kind: ErrorKind.Validation,
        Message: "Safety-related work orders need a completion photo before they can be closed."
    })
)

It took her twenty minutes, including the time spent finding the right choice name for the status. Signe tested it with three work orders and it behaved exactly like the C# version for the cases they tried. Maribeth was delighted. Signe was pleased too, and then asked the questions that decided whether it would ever leave the developer environment.

How an automated low-code plug-in runs

Because an automated low-code plug-in runs in the event pipeline, the lessons of lesson 1 apply to it unchanged. Logic set to run before the save can change values on the row or stop the operation with an error, and it runs inside the transaction, so an error rolls everything back. Logic set to run after the save sees the stored row and can create or update related rows. Every automated low-code plug-in adds time to every create, update or delete it is registered on, and that time counts against the same two-minute limit as everything else on the message.

Signe pointed out a difference that is easy to miss. A C# step can filter on specific columns, so it runs only when they change. Maribeth checked how her low-code version decided when to run, and found that her formula had to test the values itself, because the rule ran on every update of a work order. For a table with a few hundred work orders a month that was harmless. For a busy table, such as one updated by a nightly integration, a formula that ran on every update would deserve a closer look at performance.

Bulk operations raised a similar point. When the facilities historical migration in MSBA-250 loaded thousands of rows over a weekend, every server-side rule on the table ran for each row. A rule that made one lookup per row was fine; a rule that called a connector per row would have turned a migration into a long and expensive job. Low-code or not, server-side logic needs to be designed with the largest batch in mind, not the single form a maker tests with.

Connectors and AI functions in low-code plug-ins

Low-code plug-ins can call connector actions, which is a large part of their appeal: a rule can, for example, post a message or call an external API without a flow. Microsoft documents that not every connector action is supported, and connector calls bring the same concerns as in C#: latency, failures and credentials. The prebuilt AI functions from lesson 5, such as AISummarize and AIClassify, can all be used in low-code plug-ins. Signe repeated her advice from that lesson. A generative AI call inside logic that runs before a save makes every user wait for it and can fail the save, so it belongs in logic that runs after the save, or in a flow, and its result should be a suggestion for a person to review.

Testing and support

Testing a low-code plug-in meant testing it through the data: creating and updating rows in a developer environment and checking the results, with a written list of the cases tried. Wiremu's habit of writing a trace line for every decision did not carry over directly to a Power Fx formula, so Maribeth kept the formulas short enough to reason about, split larger rules into several plug-ins with one job each, and gave each one a name and description that said exactly what it did, so that anyone looking at the table's server-side logic later could see the full picture. When something went wrong, the error message the user saw was the first clue, which was one more reason to write clear messages in Error calls.

The questions before production

The first question was status. A preview feature can change, can lose capabilities and is not covered by the same support commitments as generally available features. Microsoft had already withdrawn one of the two kinds of low-code plug-in. Building a safety rule that the college relied on in production on a preview feature meant accepting that it might need to be rebuilt at short notice.

The second was limitations. Microsoft documents several. Tables in automated plug-ins must be referenced with an explicit notation such as [@Accounts] in some formulas. Only first-party actions can be nested. Some Collect scenarios need Patch instead. Not every connector action is supported. None of these blocked the photo rule, but each could block a later change.

The third was application lifecycle. Low-code plug-ins are stored in Dataverse and can be added to solutions, so they can move through Lumenvale's pipelines. But the formula lives inside a row, not in a source file a reviewer reads in a pull request, and there were no unit tests. Signe wanted any production rule to be reviewable and testable in the same way as code.

The fourth was who owns it. A low-code plug-in written by a maker becomes server-side logic that runs for every user of the table. It needs the same review as a C# plug-in, because a mistake in it can block every save in production. Making it easier to write does not make it less powerful.

A decision tree. The first question is whether the rule can be expressed with a business rule or formula column; if yes, use that. If no, is it needed in production and important to operations; if yes, use a C# plug-in or custom API. If no, is it a simple rule for a non-critical solution or a prototype; if yes, an automated low-code plug-in is acceptable with a review. On-demand logic called from apps leads to a function or a custom API.
Lumenvale's decision guide for server-side Power Fx.

Functions in Dataverse

Functions are Microsoft's replacement for instant low-code plug-ins. A function is a named piece of Power Fx logic stored in Dataverse, with typed input parameters and output parameters. Microsoft documents the parameter types as Boolean, String, Float, Decimal, DateTime and Integer. A function can be global, or scoped to tables, and a formula can work with up to five tables. Functions run in the security context of the user who calls them, so they cannot read or change data the user could not reach directly, and they can be called from canvas apps, custom pages and Power Automate flows. Functions are also in preview.

Maribeth saw an immediate use. The Request a Transcript app showed advisers an estimated fee using a formula that looked up the rate table; the same lookup existed in another app for employer requests. A function, EstimateTranscriptFee, with an Integer input for the delivery method and a Decimal output for the fee, would put the lookup in one place.

A sketch of a Dataverse function for a fee estimate. Names are illustrative.
// Function: EstimateTranscriptFee
// Inputs:  DeliveryMethod (Integer)
// Outputs: Fee (Decimal)
{
    Fee: LookUp(
        'Transcript Fee Rates',
        'Delivery method code' = DeliveryMethod
            && 'Effective from' <= Today()
            && (IsBlank('Effective to') || 'Effective to' >= Today())
    ).Amount
}

Signe compared it with the custom API Calculate Transcript Fee from lesson 4. The function was quicker to write and easy for Maribeth to own. But it duplicated part of the rules in FeeCalculator: it ignored the recent-graduate rule, and it used Today() in the server's sense of the date, the same trap that had caused the zero-fee bug in lesson 3. Two implementations of a fee rule would drift. The team decided that fee calculations would call the custom API from both apps, and that functions were a good fit for logic that had no C# twin, such as formatting a reference number or checking a simple condition across a couple of tables.

A rule for Lumenvale

By the end of the session, Signe, Maribeth and Wiremu had written a short rule for the CoE hub to consider. Rupert added it to the agenda for the next hub meeting.

The proposed guidance for server-side Power Fx.
SituationLumenvale guidance
A simple validation or default that a business rule or formula column can expressUse the business rule or formula column; no plug-in needed
A simple rule in a non-critical solution, owned by a trained makerAn automated low-code plug-in is acceptable, in a solution, after a review by a pro developer
Any rule that operations depend on in productionA C# plug-in, with source control and tests, until low-code plug-ins are generally available and reviewed again
Reusable logic called from apps or flowsA function for small Power Fx logic; a custom API when the logic is complex, shared with code, or needs a privilege
On-demand logic of any kindNever an instant low-code plug-in; Microsoft has deprioritized them

The photo rule stayed in C#, because it protected a safety process. Maribeth's low-code version was kept in the developer environment as a teaching example. She left the session with a function she could build for a reference-number format in the Request a Transcript app, and with a clear idea of where Power Fx on the server helped and where it did not yet.

Worked problem

Reviewing a maker's low-code plug-in

A library maker built an automated low-code plug-in on the Study Room Booking table that sets the booking end time to the start time plus two hours when the end time is blank. The library asks whether it can go to production in the Campus Operations environment group.

Show solution
  1. Check whether simpler tools fit: a business rule can set a default value, but only on a form; the maker wants it for bookings from the app and the flow too, so server-side logic is justified.
  2. Check criticality: a wrong default end time is annoying but not harmful, and staff can correct it.
  3. Check the formula against the documented limitations and test it with blank, filled and invalid values.
  4. Check lifecycle: the plug-in is in the library's solution and will move through the pipeline; the formula is copied into the solution's documentation for review.
  5. Note the preview status in the release notes, with the fallback: a formula column or a small C# plug-in if the feature changes.

Answer: Approved for the library's non-critical solution, with a review, documentation and a recorded fallback.

Common mistakes

  • MistakeBuilding new on-demand logic as an instant low-code plug-in.

    InsteadUse a function or a custom API; instant low-code plug-ins are deprioritized.

  • MistakeTreating preview features as ready for critical production rules.

    InsteadUse them for non-critical rules and prototypes, with a fallback.

  • MistakeSkipping review because the logic is low-code.

    InsteadReview server-side Power Fx like any plug-in; it runs for every user.

  • MistakeDuplicating a C# rule in a Power Fx function.

    InsteadCall the existing custom API so there is one implementation.

  • MistakeAssuming low-code plug-ins support every connector action.

    InsteadCheck Microsoft's documented limitations before designing.

Summary and key terms

  • Low-code plug-ins run Power Fx in Dataverse and depend on the Dataverse accelerator; both kinds are in preview.
  • Automated low-code plug-ins run on create, update or delete of a table's rows.
  • Instant low-code plug-ins are deprioritized and replaced by functions in Dataverse.
  • Functions have typed inputs and outputs, global or table scope, up to five tables per formula, and run as the calling user.
  • Lumenvale uses them for simple, non-critical rules with review, and keeps production-critical logic in C#.
Low-code plug-in
Server-side Power Fx logic stored in Dataverse.
Automated low-code plug-in
A low-code plug-in that runs on a table's create, update or delete events.
Instant low-code plug-in
A low-code plug-in called on demand; deprioritized by Microsoft.
Function (Dataverse)
Named Power Fx logic with typed inputs and outputs, called from apps and flows.
Dataverse accelerator
The Microsoft app that provides the low-code plug-in experience.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. What has replaced instant low-code plug-ins?

    Show answer

    Functions in Dataverse.

  2. Whose permissions does a Dataverse function use?

    Show answer

    Those of the user who calls it.

  3. Why did the photo rule stay in C#?

    Show answer

    It protects a production safety process, and low-code plug-ins are in preview.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz