A CRM Plug-in extension is executed based on a message pipeline execution model when triggered by:
- An user action in the Microsoft Dynamics CRM Web application; or
- A SDK method call by a plug-in or other application
This results in a message being sent to the organization Web service. The message contains business entity information (referred as the TARGET entity) and core operation information. The message is passed through the event execution pipeline where it can be read or modified by the platform core operation and any registered plug-ins.
Execution Pipeline Process
|Event||Stage Name||Stage Number||Description||Remarks|
|Pre-Event||Pre-Validation||10||Stage in the pipeline for plug-ins that are to execute before the main system operation. Pre-validation stage occurs prior to security checks being performed to verify the calling or logged on user has the correct permissions to perform the intended operation||Executed outside the database transaction|
|Pre-Event||Pre-Operation||20||Stage in the pipeline for plug-ins that are to execute before the main system operation||Executed within the database transaction|
|Platform Core Operation||Main Operation||30||Main operation of the system, such as create, update, delete, and so on. No custom plug-ins can be registered in this stage.||Executed within the database transactionFor internal use.|
|Post-Event||Pos-Operation||40||Stage in the pipeline for plug-ins which are to execute after the main operation.||Executed within the database transaction|
Plug-ins registered for synchronous execution are executed immediately and in a well-defined order. Multiple plug-ins that are registered in each stage can be further be ordered within that stage during plug-in registration.
Images are snapshots of the TARGET entity’s attributes, before and after the core system operation, and distinct images are available in the event pipeline:
In case of an UPDATE Plug-in, the target entity only contains the updated attributes. If the plug-in requires information from the other attributes then a pre-image must be used.
The pre and post images are populated only if indicated during plug-in registration.
Regardless of whether a plug-in executes synchronously or asynchronously, there’s a two-minute time limit imposed on the execution of a (message) request. If the execution of plug-in logic exceeds the time limit, a System.TimeoutException is thrown.
This limitation is aplied to the Sandbox execution environment