Wednesday 11 May 2016

Overview of Plugin

A plug-in is custom business logic written in .NET that can integrate with Microsoft Dynamics CRM. Using plug-ins, you can fire a custom action or event on any entity
Plug-ins are set of events and run when any associated events occur. These events occur on specific condition without any user interface.


Microsoft Dynamics CRM Online, plug-ins must be registered in the sandbox.


Stages

You can set up plug-ins in the pre-stages (either pre-validation or pre-operation) or post-stages (postoperation):

Pre-Stage—Sends control to the plug-in before the real event is executed in the core system.
For example, you might attach a plug-in to the Create event of the Account entity; your code
would execute before the Account was actually created in the CRM system. With this method,
you could prevent the Account or the entity record from being created.

Post-Stage—Executed after the real event has executed in the core system. So, following the
example just described, your code would be executed only after the Account record has been
created.

These stages are participate in SQL transactions as well. So, one can use the pre-stage outside or inside a transaction, and you can do the same for the post-stage.

              The concept of using transactions now allows the rollback of a plug-in operation. If you have two different plug-ins attached to the same message of an entity and the second plug-in fails, it can now roll back the successful operation performed by the first plug-in.

           To check whether the plug-in is running in a transaction by checking the IsInTransaction property of the IPluginExecutionContext.

 The stages 20 (preoperation) and 40 (post-operation) are the ones that guarantee to be part of a transaction, whereas the 10 (pre-validation) might not be part of it.


=======================================================

Deployment Types

A plug-in in three different ways:
Server—Means that the plug-in will execute on the server. Execution will occur when users
use the web client or the Outlook Online client as well as when any workflow is executed.
Offline—Means the plug-in executes on the client’s user machine where Outlook is running.
This proves especially useful when running the Outlook client in offline mode.
Both—Executes the plug-in on the server and in the Outlook client in offline mode. Keep in
mind that the plug-in would be executed twice, once when Outlook is offline and again when it
connects to the server.
Tip
To prevent the plug-in from executing twice because of synchronization, check the
IsOfflinePlayback property of IPluginExecutionContext.

No comments:

Post a Comment