Loading...

Build Once, Use Everywhere: Modular Logic with Custom Actions

 Build Once, Use Everywhere: Modular Logic with Custom Actions

Custom Actions in Dataverse are special processes that let you create your own business logic that can be reused across apps, flows, and plugins. Instead of writing the same logic in multiple places, you can create one Custom Action and call it whenever needed — from a Power Automate flow, plugin, JavaScript, or even an API. For example, you can create a Custom Action to send an approval email, update related records, or trigger external system calls. It works like a mini workflow or API that you design yourself. Custom Actions make your solutions cleaner, reusable, and easier to maintain in Dynamics 365 and the Power Platform.



A Custom Action in Dataverse is a custom process that lets you create your own reusable business logic or operation — like a mini function or API — that can be triggered from anywhere (such as Power Automate, plugins, or apps).

What is a Custom Action? 

A Custom Action in Dataverse is a process that you can create to perform your own custom task.

It helps you:

  • Keep your business logic in one place.
  • Run that logic from different places like Power Automate, JavaScript, plugins, or even other systems using the Web API.
  • Send and receive information using input and output parameters.
  • Add your own custom operations beyond the usual ones like Create, Update, or Delete.
How Custom Actions Fit into the Execution Pipeline

Custom Actions integrate directly into Dataverse’s event execution pipeline, which includes:
  •  Pre-validation stage (10) – logic before transaction starts (security checks, validation).
  •  Pre-operation stage (20) – before data changes are committed.
  •  Main operation stage (30) – business logic or database operation.
  •  Post-operation stage (40) – notifications, async calls, integrations.


When a Custom Action is triggered, Dataverse treats it as a message in the execution pipeline. You can register plugins on this custom message to extend or modify the behavior, similar to standard messages like `Create` or `Update`.

This makes Custom Actions first-class citizens in Dataverse’s extensibility model.

Advantages Over Workflow or Plugins


 When to Use Custom Actions

Use Custom Actions when:
  • You need a reusable API endpoint to encapsulate business logic (e.g., "Approve Credit Request").
  • You want multiple triggers (Power Automate, JavaScript, external apps) to invoke the same logic.
  • You require input and output parameters to pass structured data.
  • You want to wrap multiple operations (e.g., create record, send email, update status) in a single transaction.
  • You want fine-grained security and execution control inside Dataverse.
Avoid Custom Actions for simple field updates — they’re designed for orchestrating business processes, not single-line logic.

Design Considerations

From an architectural design standpoint:
  • Define clear purpose: Each Custom Action should represent a meaningful business operation (e.g., `ApproveInvoice`, not `UpdateFieldValue`).
  • Parameter design:
    • Use input parameters for external data (strings, entity references, Boolean flags).
    • Use output parameters for results or status codes.
    • Always validate parameter types and required values.
    • Error handling: Throw `InvalidPluginExecutionException` for predictable errors; log unexpected exceptions.
  • Security model:
    • Custom Actions run in the context of the caller by default (respecting their privileges).
    • For system-level logic, consider impersonating a service account.
  • Transactions: All logic inside an Action runs within a single transaction unless you explicitly design async operations.
  • Versioning: Use naming or environment variable patterns (e.g., `new_ApproveCreditRequest_v2`) for breaking changes; avoid overwriting live logic directly.
Integration and Invocation

Custom Actions can be invoked from:
  • Power Automate / Logic Apps – via the “Perform an unbound/bound action” Dataverse connector.
  • JavaScript (client-side) – using `Xrm.WebApi.execute()` to call the Action.
  • Plugins / C Code – via `IOrganizationService.Execute()`.
  • External APIs – via the Web API endpoint (`POST /api/data/v9.2/<actionname>`).

This multi-surface accessibility makes them ideal for enterprise integrations, especially when you need a unified point of control.

Real-World Architectural Scenarios

Scenario 1: Credit Approval Process

A company’s credit request process involves validating data, fetching limits from an external system, and sending notifications.
Instead of spreading this logic across Power Automate flows and plugins:
  •  Create a Custom Action `new_ApproveCreditRequest`.
  •  Pass parameters: `CreditRequestId`, `ApprovalStatus`, `Comments`.
  •  The Action calls an internal plugin that handles validations and API calls.
  •  The same Action is reused by Power Automate and JavaScript buttons on the UI.
Benefits: Centralized logic, consistent execution, reusable interface.

Scenario 2: Integration Gateway for External Apps

External systems (e.g., SAP) can call a Custom Action API to push data (e.g., new customer or invoice).
The Custom Action performs:
  • Validation
  • Data transformation
  • Entity creation
  • Response with a custom success/error code

Benefits: Secure, governed API integration layer within Dataverse.

Scenario 3: Multi-Step Business Transaction

In a project, multiple updates (e.g., create Order, update Opportunity, send Email) must occur together.
A Custom Action ensures atomicity — all succeed or all fail, maintaining data consistency.

Benefits: Transactional integrity and simplified orchestration.

In Summary

Custom Actions in Dataverse are a cornerstone of enterprise architecture for the Power Platform.
They provide:
  • Centralized, reusable logic
  • Secure and consistent business execution
  • Seamless integration points across systems

They bridge the gap between no-code flexibility and pro-code control, empowering architects to design scalable, maintainable, and compliant solutions.

Published on:

Learn more
Power Platform , D365 CE & Cloud
Power Platform , D365 CE & Cloud

Dynamics 365 CE, Power Apps, Powerapps, Azure, Dataverse, D365,Power Platforms (Power Apps, Power Automate, Virtual Agent and AI Builder), Book Review

Share post:

Related posts

Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy