Extend the platform
The event pipeline
A plug-in implements IPlugin and is registered against a message (Create, Update, Delete, SetState, a custom API or action) and a table on a stage: 10 PreValidation, 20 PreOperation, 40 PostOperation. PreValidation runs outside the database transaction, before the platform validates the request - no images, and a failure there leaves nothing to roll back. PreOperation runs inside the transaction before the write; modify context.InputParameters['Target'] to change what is saved. PostOperation runs after the write and is the only stage where both pre- and post-images exist.
Images and context
Images are snapshots of the row before and after the change; register only the columns you need. SharedVariables pass data between steps in the same pipeline. Depth reveals cascading re-entry, so guard against loops.
Errors and limits
Throw InvalidPluginExecutionException with a user-readable message; the platform surfaces it and rolls back. Use ITracingService for diagnostics, not user messages. Sandboxed plug-ins have a two-minute timeout and a restricted memory and file budget, so long work belongs in an asynchronous step or an Azure Function.
Extending beyond plug-ins
Custom APIs define a reusable message with request and response parameters callable from the Web API and from flows. Webhooks push the execution context as JSON to an endpoint. Business events publish to Power Automate. Custom connectors and Azure Functions cover external systems; keep secrets in a connection or key vault, never in code or unsecure configuration.
Worked example
A requirement says the account must be validated before it is written and a related row must be created afterwards. Validation and field mutation go in a synchronous PreOperation step; the related row is created in a PostOperation step, or asynchronously if it calls an external service.