Export (0) Print
Expand All

Writing the Plug-in Constructor

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

The Microsoft Dynamics CRM platform has special support for a plug-in constructor that accepts two string parameters. If you write a constructor for your plug-in that accepts two string parameters, you can pass any two strings of information to the plug-in at run time. The following code shows these two parameters.

Example

[C#]
using System;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.SdkTypeProxy;

namespace MyPlugins
{
   public class AccountCreateHandler: IPlugin
   {
      public AccountCreateHandler(string unsecure, string secure)
      {
         // Do something with the parameter strings.
      }

      public void Execute(IPluginExecutionContext context)
      {
         // Do something here.
      }
   }
}

[Visual Basic]
Imports System
Imports Microsoft.Crm.Sdk
Imports Microsoft.Crm.SdkTypeProxy

Namespace MyPlugins
   Public Class AccountCreateHandler Implements IPlugin
     Public Sub New(ByVal unsecure As String, ByVal secure As String)
       ' Do something with the parameter strings.
     End Sub

     Public Sub Execute(ByVal context As IPluginExecutionContext)
       ' Do something here.
     End Sub
   End Class
End Namespace

The first string parameter of the constructor contains public (unsecure) information. The second string parameter contains non-public (secure) information. However, the secure string is not passed to a plug-in that executes while offline.

The information that is passed to the plug-in constructor in these two strings is specified when the plug-in is registered with Microsoft Dynamics CRM. When you use the PluginRegistration tool to register a plug-in, you can enter the secure and unsecure information in the Secure Configuration and Unsecure Configuration fields provided in the Register New Step form. The PluginDeveloper tool only supports the unsecure string through its CustomConfiguration attribute of the Step tag in the register.xml input file.

When programmatically registering a plug-in using the SDK, the related classes and properties for the unsecure string are sdkmessageprocessingstep.configuration and SdkMessageProcessingStepRegistration.CustomConfiguration. For the secure string, you must create an sdkmessageprocessingstepsecureconfig entity and assign its ID to sdkmessageprocessingstep.sdkmessageprocessingstepsecureconfigid.

See Also

Concepts


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft