We will learn what are Plugins in Microsoft Dynamics 365 CRM. In CRM, we can perform various levels of operations and actions which are necessary to support the organizational requirement. There are many ways to execute these operations or business logic including out-of-the-box business rules, workflows, actions, custom workflow, plugins etc. Among these. the plugins are one of the most used and a powerful method to perform any operation within the application.
What exactly are the Plugins?
A plugin is custom and configurable business logic or custom business code that you can integrate with the Microsoft Dynamics 365 CRM. The main motive of plugin code is to enhance the standard features provided by Microsoft CRM and to accomplish complex operations and logic which cannot get executed with out-of-the-box processes. The plugins acts an an event handlers which are registered as assemblies within the CRM and are triggered or executed on certain dedicated events such as create, update or delete.
Where are the plugins written and compiled in?
Plugins are written and compiled in Visual Studio by creating a class library project within .NET framework. The plugins are compiled in form of .dll assemblies and are loaded in the CRM uniquely for each entity.
On what conditions can we trigger the plugin?
The plugins are triggered on basis of allocated messages. The messages are nothing but the events which can occur in the CRM records. Below are the different types of out-of-the-box messages, events or conditions on which we can triggered the plugin.
|Message Name||Message Description||Ownership Type|
|Create||When a record is created in CRM.||User-owned entities only|
|Update||When a record is updated in CRM.||User-owned and organization-owned entities|
|Delete||When a record is deleted in CRM.||User-owned and organization-owned entities|
|Assign||When a record is assigned to a specific user in CRM.||User-owned entities only|
|GrantAccess||Grants a security principal (organization, user, or team) access to the specified record.||User-owned entities only|
|ModifyAccess||When access is modified of a specific record in CRM.||User-owned entities only|
|Retrieve||When a user or system query or open a single record in CRM.||User-owned and organization-owned entities|
|RetrieveMultiple||When a user or system queries multiple records in CRM.||User-owned and organization-owned entities|
|RetrievePrincipalAccess||When a user or system retrieve the access rights of the specified security principal (team or user) to the specified record.||User-owned entities only|
|RetrieveSharedPrincipalsAndAccess||When a user or system retrieves retrieves all security principals (users or teams) that have access to, and access rights for, the specified record.||User-owned entities only|
|RevokeAccess||When a user or system replaces the access rights on the target record for the specified security principal (organization, user, or team).||User-owned entities only|
|SetState||When user or system changes state of a record in CRM.||User-owned and organization-owned entities|
What are pipelines in plugins?
When plugins are triggered through the above mentioned messages, they can be configured to run in multiple steps using the execution pipeline of the CRM. Below are the primary plugin pipeline stages.
|Event||Pipeline Stage Name||Description|
|Pre-Event||Pre-validation||Stage in the pipeline for plug-ins that are to execute before the main system operation. Plug-ins registered in this stage may execute outside the database transaction.|
|Pre-Event||Pre-operation||Stage in the pipeline for plug-ins that are to executed before the main system operation. Plugins registered in this stage are executed within the database transaction.|
|Platform Core Operation||MainOperation||In transaction,the main operation of the system, such as create, update, delete, and so on. No custom plug-ins can be registered in this stage. For internal use only.|
|Post-Event||Post-operation||Stage in the pipeline for plug-ins which are to executed after the main operation. Plug-ins registered in this stage are executed within the database transaction.|
In what business scenarios should we choose writing a pluign?
Below are few handpicked scenarios where we can prefer developing a plugin.
- Executing complex operations which needs data flow between multiple entities.
- Want to call an external web service on certain events such as saving or updating a record.
- You want to automate processes such as sending e-mails to your customers on certain events in CRM.
- Need to execute some business logic such as updating certain fields of a record or updating related records, etc. when you create or update a CRM record.
- Dynamically calculate the field values when user opens a record.
Thus, we have learned what are the plugins in Microsoft CRM. In our further articles we learn how to develop a plugin and register it in the Microsoft Dynamics CRM 365.