Microsoft Dynamics CRM 2011 Custom Code Validation Tool Released

The purpose of this tool is to assist customers and partners of Microsoft Dynamics CRM identify potential issues with their custom JavaScript in JavaScript libraries and HTML web resources.  The Microsoft Dynamics CRM Q4 2012 Service Update will include significant changes in the web application in order to be able to support a variety of browsers such as Safari, Chrome, and Firefox.  When using JavaScript code in Dynamics CRM, it is possible that some code will stop working or cause an error when you upgrade.

This post includes details about:

  • Problem Areas
  • Red Group Issues
  • Blue Group Issues
  • False Positives
  • Microsoft Dynamics CRM 2011 Custom Code Validation Tool Setup

Problem Areas

There are two main problem areas when JavaScript customizations are upgraded to the Microsoft Dynamics CRM Q4 2012 Service Update.

  • Red Group’: Existing JavaScript uses unsupported internal functions that were removed as part of the cross browser work. Many Microsoft CRM functions used techniques that were only possible using Internet Explorer.  All supported public functions were preserved but many undocumented internal functions and properties were changed and are no longer available, even when using Internet Explorer.
  • Blue Group’: Existing JavaScript was written and tested only on Internet Explorer. It may not work correctly for other browsers. Code using the deprecated crmForm object from earlier versions of Microsoft CRM will not work for browsers other than Internet Explorer. Organizations using other browsers must upgrade their code to use the Xrm.Page object introduced for Microsoft Dynamics CRM 2011.

Note: After your Microsoft Dynamics CRM Online organization has been upgraded to the December 2012 Service update, if you have any issues caused by code in the Blue Group you may be able to address them by changing the HTML Component Support setting found in the System Settings Customization tab. Check the Include HTC support in Microsoft Dynamics CRM forms checkbox. As long as your form scripts have dependencies on these HTC components they must continue using Internet Explorer version 9 or lower. Internet Explorer 10 does not support HTC components.

The tool examines each custom JavaScript and HTML web resource in the organization that the tool is installed in. Each web resource is displayed in a list box at the top of the tool form.  Clicking each web resource will show the issues that are found with the JavaScript that is part of that web resource as shown in Figure 1 Custom Code Validation Tool UI.

Figure 1 Custom Code Validation Tool UI

  • Code that matches patterns for the Red Group is highlighted in red.
  • Code that matches patterns for the Blue Group is highlighted in blue.
  • The tool also provides a count of the number of occurrences of each JavaScript function or property that has been identified as a potential issue.

Red Group Issues

Red Group issues need to be addressed in order for users to be able to use the application as they had done previously.  These issues affect all browsers.
The following Table 1 : Red Group matching patterns contains the internal, unsupported JavaScript functions and properties that were available in previous versions of Microsoft Dynamics CRM.

Table 1 : Red Group matching patterns

‘crmGrid’ .ShowAppNav .IsValid() .SubmitCrmForm
.IsReadyToClose .detachCloseAlert .RunReport .Print
.BuildXml .BuildXmlToSubmitForm .SetFieldReqLevel .SetAllFieldsToNonReqLevel
.displayMissingValue .GetLabelControl .FireSaveEvent .HideField
.VerifyFieldIsSet .SetDeferredCmdId .CheckFormDirty .CloseAlertAttached
.SetViewportTabSection .ModifyMinimumTabHeight .GetXml .ParseXml
.RaiseOnChange .CreateInnerSlug .ResetToDefault .ResetDefault
.FormatDuration .AddDependentParameters .AddParam .AddBindingColumn
.getLookupField .Clear .Lookup .AddItems
.Items .RemoveItem .UpdateItem .IsPermissibleType
.RaiseOnAfterSelectEvent .RaiseOnChangeEvent .RaiseSetAdditionalParamsEvent .AreValuesDifferent
.RefreshLookupItemImage .GetLookupTypeIcon .attachEventHandler .GetDataXml
.SetCurrency .InitializeLookupPresence .QueryLookupPresence .SetTime
.AddOptionGroup .InsertSlugControl .UpdateOperatorControl .UpdateInnerHtml
.DeleteDataSlug .CurrentOperatorIsClear .CalculateDataSlugTabIndex .refreshTimeValue
.attachAsOnlyHandler .GetLookupControl .DefaultValue

Blue Group Issues

The following Table 2: Blue Group matching patterns identifies the code that may not work for browsers other than Internet Explorer. Some of the elements are simply references to Microsoft technologies, such as ActiveXObject, which are not supported in other browsers.  Others are references to the Document Object Model, which may have changed as part of the CRM Q4 2012 Service Update, so customers and partners will want to investigate whether these references are still valid.

Table 2: Blue Group matching patterns

.htc <msxsl:script jscript <xml
crmForm.all document.selection .createTextRange onfocusout
onfocusin onmouseleave onmouseenter style.textDecorationLineThrough
.insertCell( .insertRow( cursor:hand .item[
.rules .parentElement .tags( <script for=
:: .selectSingleNode .selectNodes .text
.xml ActiveXObject .attachevent debugger
.additionalparams .getElementById window.location.href .document.activeElement
event.cancelBubble window.openPopup .setFirstElementFocus( .loadXml
.load( .transformNode( .childNodes.length .hasChildNodes
.firstChild .lastChild .nextSibling .previousSibling
.childNodes[ .contains( .openStdDlg( dblclick
oncontextmenu .dir .innerText .outerHTML
.currentStyle .styleFloat opacity= .isContentEditable
window.navigate .srcElement .returnValue document.all
.createNode document.appendChild document.styleSheets( rows(
cells( document.forms( options( options.remove
.add( .insertAdjacentElement .insertAdjacentHTML .Save(
.SaveAndClose( .FormType .ObjectTypeCode .ObjectId
.ObjectTypeName .RequiredLevel .SetFocus( .FireOnChange
.Min .Max .DataValue .isDirty
.Disabled .SelectedOption .SelectedText .SortingEnum
.Sort .SelectedIndex .InnerText .OptionsXml
.Precision .DataXml .Text .Value
.DisplayValue .WillSubmit .DataChangeHandler .BypassValidation
.AllowFormFocus ._bSaving ._htcInitCompleted .SubmitFormId
.NO_DATA .RefreshOnSave .Visible .ForceSubmit
.Form .TimeControl .isInitialized .allowblankdate
.IsMoney .IsBaseCurrency .CurrencySymbol .CurrencyPrecision
.IgnoreCurrencySymbol .IgnoreRange .PrecisionChangeHandler .TrimValue
.MaxLength Enumerator

False Positives

This tool will identify some false positives in the JavaScript.  Any of the functions or properties listed in the tables mentioned previously that is part of commented code will be identified in the Results text box.  These can be safely ignored as the code is commented out and cannot be executed.

The tool also cannot determine the intent of the script being analyzed.  This means that it cannot determine whether the script will function correctly if it needs to interact with other custom JavaScript functions.  For example when performing feature detection it is common to detect whether a particular feature is available in the current browser and route the logic to use different code depending on the browser. In this case, code that only works for Internet Explorer would exist and does not represent a problem.

Every effort was made to identify those functions and properties being used in custom JavaScript and HTML web resources that may affect customers and partners.  The list is as comprehensive as possible, but there may be other issues that this tool does not identify that could affect the functionality of the existing customizations.  The tool should not replace standard testing practices to ensure the customizations continue to work once the CRM Q4 2012 Service Update is applied.

Microsoft Dynamics CRM 2011 Custom Code Validation Tool Setup

The tool is provided as a managed solution which can be imported into any Microsoft Dynamics CRM 2011 organization.  You must have the Import Customizations Privilege to install the solution. Users with the System Administrator or System Customizer security role typically have this privilege. To install the solution, follow these steps.

  1. Launch Microsoft Dynamics CRM using Internet Explorer with a user account that has privileges to import solutions.
  2. Log into the Microsoft Dynamics CRM organization into which you want to install the solution.
  3. Click the Settings area in the left hand navigation pane in Microsoft Dynamics CRM 2011.
  4. Click the Solutions navigation item under the Customizations sub-area in the left hand navigation pane.
  5. Click the Import button on the toolbar for the All Solutions grid view.
  6. Click the Browse button and select the folder where the file is located.
  7. Click the Next button and proceed to import the solution.
  8. Once the import completes, click the Close button to close the Import Solution dialog.
  9. Click the Publish All Customizations toolbar button on the All Solutions grid view to publish the solution.
  10. To launch the tool, double click on the CustomCodeValidationTool solution to open it.
  11. Click the Open the Custom Code Validation Tool button on the solution’s Configuration Page to launch the tool.