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.
- 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.
- 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.
- 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.
- 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>`).
- 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.
- Validation
- Data transformation
- Entity creation
- Response with a custom success/error code
- Centralized, reusable logic
- Secure and consistent business execution
- Seamless integration points across systems
Published on:
Learn moreWe can help you with Build Once, Use Everywhere: Modular Logic with Custom Actions
If you want help implementing, troubleshooting, or improving this product, contact us and we’ll point you in the right direction.
Related posts
Copilot Studio: Agent Integration Approaches — Tools, Knowledge, and Agents
In Copilot Studio, agent integration employs the same fundamental integration concepts and patterns used in traditional enterprise integration...
Copilot Studio: How to Plan Integration with Enterprise Systems
Integrating Microsoft Copilot Studio agents with enterprise systems transforms a basic chatbot into a secure, intelligent digital teammate tha...
Book Review : The Manager 's Path : A Guide for Tech Leaders Navigating Growth and Change by Camille Fournier
After a long time, I came across a book that is truly valuable for engineering students and professionals, especially those working in t...
Power Platform Environment Deep Dive (Part 2)
In Microsoft Power Platform, choosing the right environment type is important because each environment is designed for a different business pu...
Power Platform Environment Deep Dive (Part 1)
Today, in the business enterpriese world, Power Platform enables organization to build application, automate workflow, analyze data crea...
Book Review : Life 3.0 by Max Tegmark
This is the third book I’ve read this year, and even though I’m still in the early chapters, it already feels like my favorite read of the yea...
Dataverse Views Demystified: Making Data Work for You
In Microsoft Dataverse, users do not always see all the data stored in a table. What they can view depends on their security permissions, role...
Decode & Fix : Shared App host initialization has timed out in Microsoft Power Apps
Issue :While working with apps in the Microsoft Power Platform, we encountered a critical issue where the application failed to load pro...
