What is Plugin in Dynamics 365?
Plugin is custom business logic (code) which is added to dynamics 365 to extend the standard behavior.
Plugin code is written in C# or VB language in .Net Framework. The framework selected based on which Dynamics is used like Dynamics CRM 2013 version, Dynamics CRM 2015, Dynamics CRM 365 etc.
Simply if we try to create plugin for latest CRM like D365 on old framework like .Net3.5 etc then plugin solution will not compiled. So before we start plugin solution, will identify which framework is compatible.
Plugin can be executed Synchronous and Asynchronous.
Dynamics has events to work with data. Events like to create the record of particular entity/table then will use Create event. To update the record with some data then we use Update event. Similar to these there are several events in Dynamics. These are called as Messages in Plugin. On these Message/Event plugins are registered. Some of the most use plugin events/message are below, there are more events which can be utilized to custom development.
Message Name
Create
Update
Assign
Delete
merge
Retrieve
RetrieveMultiple
Qualify
SetState
SetStateDynamicEntity
etc.
When plugin is executed on particular event, then entire plugin process is divided into stages. These stages are called pipeline stage. Each stage has number which are used in plugin to validate or add the logic based on stage.
When CRM perform its operation like create, update, delete etc then plugin can be in Pre-Event and Post-Event.
In Pre-Event, there are two pipeline stage as below.
- Pre-Validation - Stage: 10
- Pre-Operation - Stage: 20
When CRM performs logic operation then itself is a step but we can not use that stage since it is used by CRM itself for operation.
- CRM Core Operation - Stage: 30
When CRM has performed it action then it has Post-Event. On Post-Event there is only one Stage as below.
- Post-Operation - Stage: 40