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 more