Free Plugin Configuration Solution Released

I updated my Plugin Configuration solution to work as a real solution within Dynamics CRM 2011.

You will find it on the Free Solutions page.

Included in the zip file are:

  • An unmanaged solution
  • A managed solution
  • Sample code ( below )

 

Usage:

Perform the following steps to add the solution to your system:

1. Import the solution into CRM. In the Settings area, you’ll find a Plugin Settings link.

2. Add a record to specify a plugin configuration setting. There are three parameters:

  • Plugin Name
  • Setting Name
  • Setting Value

As shown in the figure below:

image

 

In your plugin, you’ll need to add a method to extract get your setting:

public static string GetPluginConfigSetting(IOrganizationService service, 
                       string pluginName, 
                       string pluginSettingName)
{
    var queryByAttribute = new QueryByAttribute("m3_pluginsetting");
    queryByAttribute.Attributes.AddRange(new [] { "m3_pluginname", "m3_settingname" } );
    queryByAttribute.Values.AddRange(new object[] { pluginName, pluginSettingName });
    queryByAttribute.ColumnSet = new ColumnSet();
    queryByAttribute.ColumnSet.AddColumn("m3_settings");

    var retrieved = service.RetrieveMultiple(queryByAttribute);

    if (retrieved.Entities.Count > 0)
    {
        return retrieved.Entities[0].Attributes["m3_settings"].ToString();
    }

    throw new InvalidPluginExecutionException(
              "Unable to retrieve configuration settings.");
}

 

This method is called like this:

UnsecureInformation = GetPluginConfigSetting(crmService, "MyPlugin",
                                            "ConnectionString");

 

 

Alternatives

The Adxstudio Productivity Pack for Dynamics CRM 2011 has a similar feature so that is an alternative if you need one.

Leave a Reply 0 comments