MS CRM 2011 Plugins FAQ

Following post contains frequently asked questions about plugins. You will find info about:
  • Isolation mode
  • Where secondary entity is used
  • Where to store plugin assemblies
  • Pre/Post Images, Target entity
  • How to access secure\unsecure configurations and what is the difference
  • Pipeline stages descriptions
  • e.t.c.


Which Isolation Mode should I choose?


Sandbox (recommended option)
pros cons
Supported by all types of CRM deployment You haven’t got access to the file system, system event log, certain network protocols, registry
Supports run-time monitoring and statistics reporting
Secure approach
MS CRM monitors sandbox worker process and handles situations of CPU/memory/handle limits exceeding.

None
pros cons
All power of .NET framework is in your hands Not supported by CRM online
Doesn’t support monitoring and statistic


Which Assembly Storing variant should I choose?


Database
pros cons
This is recommended option in production environment
You should register assembly once, even if you have several servers
During recovery of the server you don’t need any additional step
Supported by all deployment scenario

Disk
pros cons
This is recommended option in development environment You should place assembly in the \server\bin\assembly directory on each server.
You need just copy assembly to redeploy newer version

GAC
pros cons
You should place assembly in GAC on each server.
I have never used this option.


Where is Secondary Entity used?


The secondary entity only applies to the SetRelated and RemoveRelated messages.


What is secure/unsecure configuration? How to access secure/unsecure configurations in the plugin?


  • Secure Configuration is not passed to plugins running in the CRM Outlook Client
  • Secure Configuration Strings for plugins do not get imported with the plugin steps when importing a solution to another organization
  • Only system administrator can read secure configuration

Use following code to get configurations inside plugin

    public class ConfigsPlugin : IPlugin
    {
    private string _sConf = null;
    private string _usConf = null;

    public ConfigsPlugin(string unsecureConfig, string secureConfig)
    {
    _sConf = secureConfig;
    _usConf = unsecureConfig;
    }

    public void Execute(IServiceProvider serviceProvider)
    {
    }
    }
  


What is the difference between PreImage, PostImage, Target Entity?


1. Target Entity available on all steps and contains entity passed in the request message. You can update Target entity on Pre-stage and those changes will be post into the database. Changes on Post-stage don’t affect database.

2. PreEntityImages and PostEntityImages contain snapshots of the primary entity's attributes before and after the core platform operation. Following tables describes PreImage, PostImage availability:

Pre-Image Post-Image
Pre Post Pre Post
Create No Yes No Yes
Update Yes Yes No Yes
Delete Yes Yes No No

Note. Target entity only contains attributes platform needs to update.


Which Pipeline Stage should I choose?


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. The 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.

Pre-operation
Stage in the pipeline for plug-ins that are to execute before the main system operation. Plug-ins registered in this stage are executed within the database transaction.

Post-operation
Stage in the pipeline for plug-ins which are to execute after the main operation. Plug-ins registered in this stage are executed within the database transaction.