Saturday, July 12, 2014

Event Pipeline in Plug-in

Plug-in Event Pipeline

The event pipeline allows you to configure when in the event the plug-in code will execute. The event pipeline is divided into the following events and stages:
Pre-event/Pre-Validation
This stage executes before anything else, even before basic validation if the triggering action is even allowed based on security. Therefore, it would be possible to trigger the plug-in code even without actually having permission to do so and great consideration must be used when writing a pre-validation plug-in.  Also, execution in this stage might not be part of the database transaction.
Example uses:
Some "delete" plug-ins. Deletion cascades happen prior to pre-operation, therefore if you need any information about the child records, the delete plugin must be pre-validation.
Pre-event/Pre-Operation
This stage executes after validation, but before the changes has been committed to database. This is one of the most commonly used stages.
Example uses:
If and "update" plug-in should update the same record, it is best practice to use the pre-operation stage and modify the properties. That way the plug-in update is done within same DB transaction without needing additional web service update call.

Post-Event / Post-Operation
This stage executed after changes have been committed to database. This is one of the most used stages.


No comments:

Post a Comment