Monday, September 21, 2015

Configuration for CRM Plugins

CRM plugins are always great feature where we can automate many functionality which we cannot automate from user interface. But almost everyone of us might a faced a scenario where we may have to configure some data for the plugin to work. There are multiple solutions for such a situation like, create a custom entity where we can configure the data needed. But that can be costly if the configuration is required only for one plugin. In such a case, plugin itself has a feature for the same.

May be you have already noticed this feature while registering the plugin on the right hand side of the window where we create a step for the plugin. We have two types of configurations, secure and unsecure which differs only on how they are stored. The configurations can be of any format (like xml) but of type string. 

Now, let us discuss how to retrieve the same in our plugin code and use it. When we create a plugin include, a constructor for the plugin class, which takes two parameters of type string as follows,

public class SamplePlugin:IPlugin
{
    public SamplePlugin(string unsecureConfig,string secureConfig)
    {
       /* Now we have our configuration in the same format how it was added to          the plugin tool in the form of two parameters. The same can be extracted          as required for our implementation and use the same across the plugin. */
    }
}

A detailed way of implementation can be found here which is using an xml format to save configuration.

If different options with the advantages and disadvantages are to be discussed the information can be found here.

Configuration for CRM Plugins

CRM plugins are always great feature where we can automate many functionality which we cannot automate from user interface. But almost eve...