Optimise Dynamics CRM 2011 using WCF Compression

IIS automatically compresses many types of content including script, images and css files to help improve network performance by minimizing the amount of data required to be transferred between the client and server. WCF responses which have a mimetype of ‘application/soap+xml;charset=utf-8’ are not compressed by default by IIS.

Dynamics CRM 2011 Outlook client uses WCF to retrieve data from the server and minimizing the network traffic across these clients especially when there are a large number of Dynamics CRM Outlook client users can have a positive impact on network load freeing up resource for other processes.

With WCF compression enabled you may see up to 30% reduction in response size and you can discover this by analyzing network traffic before and after it is enabled. The largest benefit that can be obtained from compression is by enabling SSL for your Dynamics CRM deployment, even for on-premise. Using SSL you may be able to gain an 80% reduction in the response size for your Dynamics CRM Outlook clients. The side effect to all of this is the impact on server resource in particular CPU when it performs the compression and with SSL, the encryption. Therefore it may not provide benefits in every scenario though weighing up the different aspects of your environment including the amount of users, and performance testing these features may show a positive increase in network performance.

Enable compression using a command line

  • Open the Command Prompt on the CRM Server.
  • Run the following command:

%SYSTEMROOT%\system32\inetsrv\appcmd.exe set config -section:system.webServer/httpCompression /+”dynamicTypes.[mimeType='application/soap+xml; charset=utf-8',enabled='true']” /commit:apphost

  •  Reset IIS for the setting to take effect.

Enable compression by manually updating the ApplicationHost.Config

  • On the CRM Server Navigate to: C:\Windows\System32\Inetsrv\Config\applicationHost.config and open it with notepad.
  • Locate the Section: “<httpCompression directory=” and in that section find a child node titled <dynamicsTypes> and an entry that looks like this:
    <add mimeType=”application/x-javascript” enabled=”true” />
  • Below that, add the following line:

<add mimeType=”application/soap+xml; charset=utf-8″ enabled=”true” />

  • Save the file and reset IIS for the setting to take effect.

Enable Compression in IIS using Configuration Editor

  • Open IIS on the CRM Server
  • Open Configuration Editor and navigate to the system.webServer/httpCompression Section

  • Choose dynamicTypes and open to add the new mimeType
  • Add a new item and enter application/soap+xml; charset=utf-8 as the mimeType.

  • Enable the mimeType and close the window.
  • Select Apply on the Configuration Editor and then reset IIS for the setting to take effect.

Note: Ensure you test this thoroughly in a test environment before configuring your production environment with this setting.

Updated CRM 2011 Download Links

Here is an updated list of available CRM 2011 RTM downloads. It is good practice to have these files on a portable drive but it’s also recommended to have an updated list of download links.

Component URL
Server http://www.microsoft.com/download/en/details.aspx?id=27822
Outlook Client http://www.microsoft.com/download/en/details.aspx?id=27821
Language Pack http://www.microsoft.com/download/en/details.aspx?id=27819
Email Router http://www.microsoft.com/download/en/details.aspx?id=27818
Report Extension http://www.microsoft.com/download/en/details.aspx?id=27823
SharePoint List http://www.microsoft.com/download/en/details.aspx?id=5283
Software Development Kit http://www.microsoft.com/download/en/details.aspx?id=24004
Implementation Guide along with additiional Planning Tools http://www.microsoft.com/download/en/details.aspx?id=3621

CRM 2011 Grid with Preview Form

A sample of this html file can be downloaded from my Skydrive here http://sdrv.ms/RbwsKr

 

 

This week I was asked about showing an associated grid view and preview form within a Silverlight application similar to the way Outlook has a grid/preview layout. There are a couple of ways to do this and the one most obvious is to use the Silverlight controls and simply bind the CRM data to them. One alternative I pondered was to reuse the existing CRM Grid and CRM Form in IFrames on a HTML Page. This page could then be loaded into CRM as a Web Resource and opened by a Silverlight application or linked to in SiteMap, etc…

The main advantage to this approach is that any changes to the CRM form fields or grid columns would not require any change to be implemented to this html page, where as using a full Silverlight app you would have to update the application aswell. I’m going to show you the pieces of the prototype I built and hopefully you may be able to take this further for your own benefit. Here is a screenshot of the layout of the html page.

The html body consists of 2 iframes, one for the grid and the other for the form. In this example the grid is loading the Contact’s Activities associated grid view.

<body onload="Initialise()">

</body>

I have a number of constants for this prototype demo but some of these you will want to determine from a querystring or ClientGlobalContext.js.aspx file,

// You should collect the the server address and org values using the ClientGlobalContext.js.aspx file <a href="http://msdn.microsoft.com/en-us/library/gg328541.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/gg328541.aspx</a>
var server = "http://crm:5555"; // server url with port, if port required
var orgName = "Playground";

//  grid related settings
var entityId = "<A Guid Value goes here>"; // e.g. 00000000-0000-0000-0000-00000000000
var entityType = "2"; // Entity type for Contact
var areaView = "areaActivities"; // Activities associated view id found in Left hand Nav Pane by viewing DOM
//var areaView = "areaOpps"; // Opportunities associated view id found in Left hand Nav Pane by viewing DOM
var internalGridElement = "crmGrid_Contact_ActivityPointers"; // Activity Grid found in DOM
//var internalGridElement = "crmGrid_opportunity_customer_contacts"; // Opportunity Grid found in DOM

The body onload simply calls Initialise which sets the uxGrid iframe.

// Initialise page, set grid iframe
function Initialise() {
    document.getElementById("uxGrid").src = server + "/" + orgName + "/userdefined/areas.aspx?oId=%7b" + entityId + "%7d&oType=" + entityType + "&security=000000&tabSet=" + areaView;
}

When the grid loaded and when I selected a new view on the grid I received the ‘Error on Page’ and after tracing through the script I found that I could simply provide some stubs which handle the calls executed by the grid. I return null and I haven’t seen any functional issues arise from this during my testing.

// Stubs to handle grid in an IFRAME, errors occur otherwise
var Mscrm = new Object();
Mscrm.PageManager = new Object();
Mscrm.PageManager.get_instance = function() { return null; }

var crmRibbonManager = null;

$find = function(e) {
    return null;
}
// End Stubs

The following functions provide the functionality for the form preview to load. LoadPreviewPane is called when you single click a row in the grid. CleanFormWindow removes the form ribbon, left hand nav pane, footer and also disables all fields on the form.

// Show form in preview area
function LoadPreviewPane(entity) {
if (entity != null) {
document.getElementById("uxPreview").style.visibility = "hidden";
document.getElementById("uxPreview").src = server + "/" + orgName + "/main.aspx?etn=" + entity.TypeName + "&extraqs=" + escape("&id=" + entity.Id) + "&pagetype=entityrecord";
}
else {
document.getElementById("uxPreview").src = "about:blank";
}
}

// Remove chrome from around form in preview area
function CleanFormWindow() {
    if (event.srcElement.readyState == "complete") {
        var frameDoc = document.getElementById("uxPreview").contentWindow.document;

        if (frameDoc && frameDoc.getElementById("contentIFrame")) {
if(frameDoc.getElementById("perceivedRibbonId")) frameDoc.getElementById("perceivedRibbonId").style.display = "none";
frameDoc.getElementById("crmTopBar").style.display = "none";
 frameDoc.getElementById("crmContentPanel").style.top = "0px"; // Move Form Content area up to top of window, initial style.top is 135px
 frameDoc.getElementById("crmContentPanel").style.height = "100%";
 frameDoc.getElementById("contentIFrame").style.height = "100%";

 frameDoc.getElementById("contentIFrame").onreadystatechange = function() {

 if (frameDoc.getElementById("contentIFrame").readyState == "complete") {
 try {
 // Hide Left Hand Nav bar / pane
 frameDoc.getElementById("contentIFrame").contentWindow.document.getElementById("crmNavBar").parentElement.style.display = "none";
 frameDoc.getElementById("contentIFrame").contentWindow.document.getElementById("tdAreas").parentElement.parentElement.parentElement.parentElement.colSpan = 2;
 frameDoc.getElementById("contentIFrame").contentWindow.document.getElementById("tdAreas").parentElement.parentElement.parentElement.parentElement.style.height = "100%";

 // Hide the Breadcrumb and Record Set Toolbar
 frameDoc.getElementById("contentIFrame").contentWindow.document.getElementById("recordSetToolBar").parentElement.style.display = "none";

 // Hide the Form Footer Bar
 frameDoc.getElementById("contentIFrame").contentWindow.document.getElementById("crmFormFooter").parentElement.style.display = "none";

 // make everything readonly on the form using Xrm.Page controls
 frameDoc.getElementById("contentIFrame").contentWindow.Xrm.Page.ui.controls.forEach(SetControlDisabled);

 // Everything is finished so show the form
 document.getElementById("uxPreview").style.visibility = "visible";
 } catch (ex)
 { }
 }
 }
 }
 }
}

// Delegate function for disabling control in form control collection
function SetControlDisabled(control,index)
{
control.setDisabled(true);
}

The AttachGridEvent function attaches the GridClick function to the onselectionchange event of the internalGridElement defined in the constants earlier. A line of code sets the grid to single row selection to prevent a user from selecting multiple rows.

function AttachGridEvent() {

if (document.getElementById("uxGrid").readyState == "complete") {
var frameDoc = document.getElementById("uxGrid").contentWindow.document;
if (frameDoc.getElementById(internalGridElement) != null) {
frameDoc.getElementById(internalGridElement).attachEvent("onselectionchange", GridClick);
// Set grid to single select
if(frameDoc.getElementById(internalGridElement).document.getElementById("max"))
frameDoc.getElementById(internalGridElement).document.getElementById("max").value = 1;
}
}
}
// GridClick function for onselectionChanged event
var bFired = false;
function GridClick() {
selectedItems = new Array();

var grid = null;

//    get array of selected records
var frameDoc = document.getElementById("uxGrid").contentWindow.document;

if (bFired == false) {

if (frameDoc.getElementById(internalGridElement)) {
grid = frameDoc.getElementById(internalGridElement).control;
if (grid.get_selectedRecordCount() > 0) {
var records = grid.get_selectedRecords();
// record object fields
// Id
// Name
// TypeCode
// TypeName
LoadPreviewPane(records[0]);
}
else {
LoadPreviewPane(null);
}
}
bFired = true;
}
else {
bFired = false;
}
}

Hopefully you are able to reconstruct a html page from these examples and remember you must import the html page as a Web Resource otherwise you will end up with a cross domain error.

Microsoft Dynamics CRM 2011 Administration Bible

Fellow MVP Matt Wittemann and Greoff Ables have produced the perfect guide to CRM 2011 for newcomers and MS CRM seasoned professionals. I highly recommend this book for people new to CRM 2011 but I also think  those already working with CRM 2011 should check it out. I’ve been reading through it this past week and have been finding things that I didn’t even know… and wish I had. It shows the knowledge and understanding Matt and Greoff have of Microsoft’s latest incarnation of CRM which seems second to none.

This book is more than just for admins, it covers a wide area of topics including a great introduction on CRM and the planning involved when choosing to implement it. So much is covered in this book from installation, customisation, extending,  integration, reporting and also how to use CRM 2011. If you’re about to start a CRM 2011 project or currently implementing one, or you just want to learn CRM 2011, this book is a great place to start and also build up your knowledge on this excellent product.

Microsoft Dynamics CRM 2011 RTM released

The CRM Team released  CRM 2011 RTM today (16th Feb 2011), along with an updated SDK, Implementation Guide, Outlook client, Email Router, SharePoint List Component and Reporting extension. You can follow the links below to download. Have fun!!     Also you can find the Microsoft press release here.

Component URL Language Availability
Server
http://www.microsoft.com/download/en/details.aspx?id=27822 Available in English only
Outlook Client
http://www.microsoft.com/download/en/details.aspx?id=27821 Available in 25 languages
Language Pack http://www.microsoft.com/download/en/details.aspx?id=27819 Available in 41 languages
Email Router http://www.microsoft.com/download/en/details.aspx?id=27818 Available in 25 languages
Report Extension http://www.microsoft.com/download/en/details.aspx?id=27823 Available in 25 languages
SharePoint List http://www.microsoft.com/download/en/details.aspx?id=5283 Available in 41 languages
Software Development Kit
http://www.microsoft.com/download/en/details.aspx?id=24004  
Implementation Guide along with additiional Planning Tools http://www.microsoft.com/download/en/details.aspx?id=3621  

To activate the CRM 2011 Server, please use the following keys:

MQM2H-JYYRB-RRD6J-8WBBC-CVBD3 (Server)

H84KC-JH8DF-7PDYK-TXBXR-2RMMT (Workgroup)

Microsoft Dynamics CRM 2011 RC Updates Available

There are a number of critical updates available for the CRM 2011 RC Server, Email Router and Outlook Client and if you haven’t accepted to have these downloaded automatically via Windows Update then you can download them from here manually. The KB Article can be found here.



Microsoft Dynamics CRM 2011 Beta Server and Outlook Client Updates

There are a number of critical updates available for the CRM 2011 Beta Server and Outlook client and if you haven’t accepted to have these downloaded automatically you can download them from here manually.