The Microsoft Dynamics GP installer adds several actions to Communicator that allow the user to perform actions in the Microsoft Dynamics GP client. You can add your own actions to the Communicator client.
To add an action to Communicator, you must add a key containing several values to the Windows Registry. To do this, complete the following steps:
Using a tool like RegEdit, open the Windows Registry.
In the registry, create a new key in the following location:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Communicator\SessionManager\Apps\
Supply the new key a with a GUID name similar to the other keys in this location.
The name of the key is important. How this name sorts alphabetically with the other GUID entries determines its position in the menus built by Communicator. |
Add the following values to the new key:
ApplicationType A REG_DWORD value that specifies the protocol to use for the Communicator action. For actions performed in Microsoft Dynamics GP, the Dynamics GP Protocol handler is used, so this value is set to 1.
ExtensibleMenu A string value that specifies where the action will be displayed in Communicator. Set this value to the following string:
MainWindowRightClick;ConversationWindowContextual
Name A string that specifies the name displayed for the action.
Path A string specifying the action to perform. Typically, this will be a call to the Dynamics GP Protocol Handler. The following is an example of a call to the protocol handler:
dgpp://UnifiedCommunications/Dynamics?ProductID=3333&ActionType=OPEN& FunctionName=OpenNewLead&UserSIP=%user-id%
The call must begin with dgpp://UnifiedCommunications/Dynamics. The query string (everything following the question mark) can contain whatever name/value pairs are required so the action can be performed. For example, you will want to pass a product ID and an indicator of the action to perform. You can use the token %contact-id% to include the SIP address of the person selected in Communicator. The token %user-id% can be used to include the SIP address of the person performing the action.
SessionType A REG_DWORD value that should be set to 0 to indicate the session will be local.
SmallIcon A string value that indicates the path of the icon to display. If the icon can’t be found, a default icon is displayed. Two icons are included with Microsoft Dynamics GP for the Communicator integration:
These are found in this location for 32-bit systems:
C:\Program Files\Microsoft Dynamics\GP\Background\Images\
They are found in this location for 64-bit systems:
C:\Program Files (x86)\Microsoft Dynamics\GP\Background\Images\
Typically, the Microsoft Dynamics GP Protocol Handler is used to perform an action that is started from within Communicator. The code that performs the action is contained in an add-in that is created with Visual Studio Tools. Refer to the Visual Studio Tools Programmer’s Guide for general information about how to create an add-in.
The Visual Studio Tools add-in that will respond to the action must reference the Microsoft.Dynamics.GP.DrillBackWcfService assembly, found in the AddIns folder of a Microsoft Dynamics GP installation.
In the Initialize() section of the add-in code, you will create a service instance. You will also add an event handler to process static URI events. In the event handler, you need to parse the query string that is passed in through the URL to determine whether it is your action that needs to be processed. Special routines in the .NET Framework can help you process the query string.
The following C# code example is a Visual Studio Tools add-in that handles the Communicator action for the sample integrating application. Note the following items in the code:
using System; using System.Collections; using System.Collections.Specialized; using System.Collections.Generic; using System.Text; using System.Web; using Microsoft.Dexterity.Bridge; using Microsoft.Dexterity.Applications; using Microsoft.Dynamics.GP.ServiceIntegration.DrillBackService; namespace SampleGPHandler { public class GPAddIn : IDexterityAddIn { // Variable for the service instance DynamicsGPDrillBack ServiceInstance; public void Initialize() { // Get the service instance ServiceInstance = DynamicsGPDrillBack.Instance; // The static instance must be used for Unified Communications ServiceInstance.ProcessStaticUri += new EventHandler <UrlReceivedEventArgs>(ServiceInstance_ProcessStaticUri); } void ServiceInstance_ProcessStaticUri(object sender, UrlReceivedEventArgs e) { string ProductId = ""; string ActionType = ""; string FunctionName = ""; string UserSIP = ""; // Process the query portion of the URL that was passed in NameValueCollection KeyPairs = HttpUtility.ParseQueryString(e.UriValue.Query); foreach (string key in KeyPairs.Keys) { if (key == "ProductID") { ProductId=KeyPairs.GetValues(key).GetValue(0).ToString(); } if (key == "ActionType") { ActionType=KeyPairs.GetValues(key).GetValue(0).ToString(); } else if (key == "FunctionName") { FunctionName=KeyPairs.GetValues(key).GetValue(0) .ToString(); } else if (key == "UserSIP") { UserSIP = KeyPairs.GetValues(key).GetValue(0).ToString(); } } // If it is our product, then perform the action if (ProductId == "3333") { if (FunctionName == "OpenNewLead") { // Open a new lead if one isn't already open if (SampleIntegratingApp.Forms.IgLeadMaintenance.IsOpen == false) { SampleIntegratingApp.Forms.IgLeadMaintenance.Open(); } } } } } }