Study FAQ
When should I use PreValidation, PreOperation, or PostOperation for a Dataverse plug-in?
Also asked as 2
- Which Dataverse pipeline stage should enforce a rule before a row is saved?
- How do I choose a Dataverse plug-in stage when a rule can reject or change a write?
Answer
Use synchronous PreValidation for an early rejection check and synchronous PreOperation for logic that needs to inspect or change values immediately before a standard-table write. Use synchronous PostOperation to work with the operation result inside the transaction, or asynchronous PostOperation for follow-up work that may run after the original write completes. Dataverse event framework
The initial PreValidation step normally runs before the database transaction and the platform's permission check for that operation. A nested request can reach PreValidation inside its caller's transaction, so use IsInTransaction if your logic depends on that distinction. Reject an invalid synchronous operation with a controlled InvalidPluginExecutionException. PreOperation always runs before the main write and can change submitted fields directly on the Target entity for Create or Update. A synchronous PostOperation exception can roll back a standard-table write. Elastic-table writes have different transaction behavior, so validate before the main write there as well. Plug-in registration stages · Handle plug-in exceptions · Elastic table behavior
Choose the stage around the rule's inputs. A maintenance-window check that must see timestamps normalized by an earlier PreOperation step can run synchronously after that step and reject an invalid result. Test a valid write, a rejected write and any legitimate nested request through the registered operation. Inspect the stored row and the returned result for each case.
Full explanation
AB-400: Dataverse Plug-ins and the Event Execution Pipeline
Study guide · AB-400
Read the full explanation