Microsoft Dynamics CRM and Add-in Express 2010, part 2
Welcome to the second part of the Microsoft Dynamics CRM focused blog series. In part 1, we discussed how to customize the MS Dynamics CRM Outlook Client. In this post we’ll continue to use Add-in Express 2010 to further customize the Outlook client and provide our users with an alternate user interface to MS Dynamics CRM.
As I’ve mentioned in the previous post, MS Dynamics CRM creates a folder structure in MS Outlook. Clicking on one of the folders displays the related CRM view, which in effect is simply a link to the CRM html view on the CRM server. In this post, we’ll replace the default html view with a spiffy windows forms view, and provide the user with the choice of either using the windows forms view or standard html view.
First, we’re going to replace the standard properties window for the Accounts folder, to hide most of the complexities from the user and give them the ability to switch between different folder views.
Right. In order to do this, let us create a new ADX COM Add-in project in Visual Studio 2010.
Finish the wizard in the standard fashion. In this scenario we’ll only use Office 2010 and Outlook. Once the wizard is completed, add a new Outlook Property Page Item to the project.
Switch to the AddinModule designer page, and click on the ellipses(…) button next to the FolderPages property. Click on the add button to add a new item to the ADXOLFolderPage Collection, change the FolderName property to Microsoft Dynamics CRM\Marketing\Accounts, the PageTitle property to Alternate View and finally select the property page you’ve added previously from the PageType property’s dropdown list. The should look similar to this:
At this point you can build and run your project, when you right click on the Marketing\Accounts folder under Microsoft Dynamics CRM and click on the properties menu item, you will notice that the folder property page now has an extra tab:
I’ve added two radio buttons to the PropertyPage for the user to select which view to use for the folder. Next, we need to add an Add-in Express Outlook form item to our project:
This will be used to built the alternate Windows forms View. Next, we’ll hook up the newly created Outlook form to display instead of the default Dynamics CRM View. To do this, switch to the AddinModule designer and add a new ADXOutlookFormsManager. Click the ellipses(…) next to it’s Items property and add a new Item to the ADXOlFormsCollection by clicking the Add button.
Change it’s name to accountsWebView and set the ExplorerLayout property to WebViewPane. In the FormClassName property, select the Outlook forms you’ve added previously from the dropdown list. Click OK to close the ADXOlFormsCollection Editor window.
Next, we need to add some code logic to display the alternate views depending on what the user has selected. Open the PropertyPage you’ve added earlier and switch to its code view.
I’ve added the following code to the one radio button’s CheckedChanged event:
private void rbWebView_CheckedChanged(object sender, EventArgs e) { Outlook._Application OutlookApp = (AddinExpress.MSO.ADXAddinModule.CurrentInstance as SpiffyCRM.AddinModule).OutlookApp; Outlook.Explorer activeExplorer = OutlookApp.ActiveExplorer(); Outlook.MAPIFolder currentFolder = activeExplorer.CurrentFolder; if (rbWebView.Checked) { (AddinExpress.MSO.ADXAddinModule.CurrentInstance as SpiffyCRM.AddinModule).accountsWebView.FolderName = ""; currentFolder.WebViewURL = "https://crmserver:5555/NorthwindTraders/_root/stage.aspx?url=%2FNorthwindTraders%2F_root%2Fhomepage.aspx%3Fetc=1&id=nav_accts"; currentFolder.Display(); } else { (AddinExpress.MSO.ADXAddinModule.CurrentInstance as SpiffyCRM.AddinModule).accountsWebView.FolderName = @"Microsoft Dynamics CRM\Marketing\Accounts"; currentFolder.Display(); } }
Essentially, what the above code does, is when the user selects that he would like to see the Winforms UI, we programmatically set the FormsManager’s item FolderName property to the desired MS Dynamics CRM folder. The reverse simply sets the folder’s WebViewURL property back to the original MS Dynamics CRM location.
And as easy as that your user can have a choice between the standard MS Dynamics CRM view:
or our newly created Winforms View:
Thank you for reading. Until next time, keep coding!