Tuesday, 23 July 2013

Dynamics CRM 2011 Outlook Client Optimization

With the introduction of CRM rollups e.g. RU12 with cross browser support I've noticed the CRM Outlook client is struggling and crashing more often possibly due to all the new changes in the new rollups a number of tweaks and optimizations are available to improve the user experience when using the CRM outlook client.

Making CRM 2011 Outlook client stable
I've noticed Outlook clients started to crash randomly after the deployment of RU11 analysing Outlook.exe crash dumps revealed the issue was on SQL CE 3.0. A new version of SQL compact edition is available version 4.0 which as documented, handles memory better eliminating (or near) the out-of-memory crashes in Outlook while working with the CRM Outlook client.

The following Microsoft KB article documents how to upgrade SQL CE 4.0:

The process as per KB article:
  1. Install SQL CE 4.0
  2. Delete the CRM 2011 client current configuration and delete any cashed databases
    1. C:\Users\[user]\AppData\Local\Microsoft\MSCRM
      1. delete all *.sdf files
  3. EDIT the configuration wizard config file to load the SQL CE 4
  4. EDIT the  CRM client startup config file to load new assemblies.
  5. Open Outlook and confirm the new SQL CE is loaded as per below screenshot

However I found that on random machines the configuration wizard failed to connect to CRM, the reason behind this was related with a configuration line on the configuration wizard config file:

    <defaultProxy useDefaultCredentials="true" />

Removing the above code allowed the connection to be made. If you don't want to remove the above code from every user the following hotfix will resolve the issue:
CRM 2011 client x64
If you have the opportunity to instead of 32bits use the 64bits version of Office, then it would be strongly recommended to use the x64 it adds extra stability to Outlook and CRM client, as 64 bits has more room for memory allocation.

  Registry Keys
 As per the following KB http://support.microsoft.com/kb/2585157 the below registry keys will improve performance:

set to 3600000 (Decimal)
StateManagerPollInterval set to 10 (Decimal)
ActiveCachesUpdatingPeriodMilliseconds set to 3000000 (Decimal)
IncrementalDataCachesInclusionUpdatingPeriodMilliseconds set to 6000000 (Decimal)
IncrementalDataCachesExclusionUpdatingPeriodMilliseconds set to 6000000 (Decimal

TagPollingPeriod set to 600000 (Decimal)
TagMaxAggressiveCycles 0
A couple of registry keys to consider as well:
DisableMapiCaching 1
AddressBookMaterializedViewEnabled 1

CRM Settings
From CRM settings > administration there is a few settings that you should also consider to improve user experience:
System Settings > Outlook Tab you want to increasing the default values to reduce overhead on the server and on the user side:

Privacy Settings > Error Reporting here you can configure centrally all users settings on how to deal with Microsoft errors, the advantage here is that you reduce the noise on the user side.

I've covered a few known optimizations, the most impact is SQL compact edition 4 so I strongly recommend you upgrading your outlook client deployment. I hope this was helpful please leave any questions or feedback.

Monday, 1 July 2013

Dynamics CRM 2011 using SSIS to monitor pending emails

On this article I'll walk through how to build a simple and fully supported SSIS package to track pending emails in CRM. The idea is to receive an alert email when we reach a threshold suggesting email router is stuck, slow performance or unusual mail activity in CRM.

On this tutorial I use the SSIS CozyRoc component to connect to Dynamics CRM, you can download it here:

The package process:

  1. Connect to a CRM organisation using the API
  2. Run FetchXML to retrieve all pending emails
  3. Count how many emails pending and storing the total number in a variable
  4. Use an IF THEN ELSE statement to set the flow of the package to successful or failure based on the total number of emails pending
  5. send an alert email if successful or failure.

In visual studio go to: New > Project > Integration Services Project

The first step is to create a variable that will hold the total number of emails within the Control Flow tab select view and variables, this will display the variables screen on the left, click new variable and name it: RowCount, the scope should be set to 'Package' this means our variable is a global variable so it can be used either in the 'Data Flow' or 'Control Flow' area.

The next step is to create a connection to CRM to retrieve the data we want.
On the connection Managers diaglog box, right click and select New Connection. From the list choose DYNAMICS-CRM CozyRoc

The following screen should appear, configure it with your CRM information:

I renamed my connection as SandBox Connection as per below screenshot:

Next Step is to build your Data Flow tasks, click on the Data Flow tab and drag the Dynamics CRM source task on to the Data Flow area. 

Note: the Dynamics CRM Source should be available on the bottom of your Toolbox, if you have installed the CozyRoc Component and you don't see it there is because you didn't complete the post-install steps, you need to add those two tasks to the General section of the Toolbox

Also drag the Row counter task and the Data Flow area will look like this:

Note: we haven't linked the Dynamics CRM source with the row counter task we will do this soon.

Double click the Dynamics CRM source task and the following window appears:

On the above screenshot the first tab, you need to select the Connection Manager, on this case we select our SandBox Connection

Click on the Second Tab:

On the above screenshot we want to make use of the FetchXML feature, so at the bottom under 'Custom Properties' on the 'InputType' change entity to FetchXML and under 'FetchXML' paste the following XML:

Click OK all done on the 'Dynamics CRM Source' task. The next step is the 'Row Count' task link the 'Dynamics CRM source' to the 'Row Count' task and double click the 'Row Count' task the following screen appears:

Here we simply set the 'VariableName' to use our global variable, on the variable selection window you should see User::RowCount tick the box and click okay. 

At this stage we run the package it will:
  1. Connect to CRM Organisation SandBox
  2. Run the FetchXML
  3. Pass the data to the Row Count task and store the total on the User::RowCount variable

Great so we the Data Flow process in place, now we need to Send an email if we have more than 100 Emails pending we want our Control Flow area to look like this:

At the above screenshot, we added a 'Script Task' task to process the data coming from the Data Flow, we then send an email either if the package runs successful or fails.

Double Click the Script Task and on the main screen ReadOnlyVariables select our variable User::RowCount

You should see this:

On the Script Task what we need to do now is to insert code to check if the variable is bigger than X if yes set to Successful completion or to Failure. On the same window click on The button at the bottom Edit Script and insert the following code under the Main() function:

The last step is to configure the 'Send Email' task to send an email in case of Successful or Failure. In this example I've added both routes (successful and Failure, however in my production environment I only have one route for when the email is bigger than X, if you understood the above code you should be able to decide how you want to apply your logic the two routes were added to this article to understand better the process flow of this package and for testing purposes you may want to receive an email saying Yes or No to confirm the package is running okay.

I hope this was useful, please leave your feedback.