Summary
In this module, you work through Contoso's equipment-provisioning scenario to write, implement, and register a Dataverse plug-in that enforces real business logic in response to a data event.
What you learned
- The event execution pipeline moves an operation through PreValidation, PreOperation, MainOperation, and PostOperation. The stage you choose determines whether a cancellation is cheap or expensive, whether a step runs synchronously or asynchronously, and how execution order settles step conflicts on the same message.
- A plug-in class implements
IPlugin, resolves the execution context from theserviceProviderparameter insideExecute, and stays stateless so a cached instance never leaks data between invocations. Context properties likeDepthand configuration data expose what the operation needs and guard against infinite loops. - Pre-images and post-images capture a row's values before and after an operation, so your plug-in can detect a change like a status transition. The Organization service lets that plug-in read and update other rows in the same transaction. Catching failures with
InvalidPluginExecutionExceptionandITracingServiceturns a crash into a useful message. - The Plug-in Registration tool uploads the compiled assembly and configures each step's message, table, stage, execution mode, execution order, filtering attributes, and entity images. The assembly and its steps then travel together as solution components when you move the logic to another environment.
With these pieces in place, Contoso's Request table now blocks a save when an employee has no allowance left. It also deducts from the Allowance record the moment a coordinator approves a request.