Passing parameters to plug-ins

While working with plug-ins, sometimes we need additional information; it may be related to another entity or some form of configuration data. If we need to read information from any other entity, we can simply use organization service methods to fetch data from the CRM. In the case of configuration, we can also create a configuration entity in the CRM and store data there, which can be read easily in plug-ins. Apart from that, we could also create XML Web resources to store this data and read it into the plug-in.

Another option available in plug-ins to pass configuration data is to use secured configurations and unsecured configurations. A secured configuration is only accessible by the CRM Administrator, other users can't read this information in plug-ins, whereas an unsecured configuration is available to every user. Apart from that, a secure configuration is not available in new environments if a plug-in having a plug-in step with a secure configuration is imported as part of a managed solution; but an unsecure configuration will be available in the new environment. We can pass our configuration data while registering plug-in steps in terms of an XML string. We can be read by plug-in constructors as follows:

public class SamplePlugin : IPlugin
{
  string FirstName = string.Empty;
  string LastName = string.Empty;
  public SamplePlugin(string unsecureConfig, string secureConfig)
  {
    FirstName = !string.IsNullOrEmpty(unsecureConfig) ? unsecureConfig : string.Empty;
    LastName = !string.IsNullOrEmpty(secureConfig) ? secureConfig : string.Empty;
  }
}

These configurations can be defined in the Unsecure Configuration and Secure Configuration sections under the plug-in step as follows:

Passing parameters to plug-ins

Plug-in step configuration

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.136.26