Google Anlatics

Wednesday, June 19, 2013

How to fix a CRM 2011 Update Rollup 12 JavaScript issues

Below link has all the information about CRM 2011 Update Rollup 12


First thing is to do is

Enable HTC behavior files in CRM 2011 UR12/Polaris/December 2012 Update

1.     Open the Dynamics CRM Web UI, Click Settings, in the left navigation click Administration, in the main area of the UI click on System Settings to launch the system settings dialog box
2.     In System Settings dialog box click the Customization Tab, and under HTML Component Support check the box for “Include HTC Support in Microsoft Dynamics CRM Forms















Microsoft Dynamics CRM 2011 Custom Code Validation Tool

Consider familiarizing yourselves with this tool… though the download page mentions Update Rollup 9, it hasn’t had much utility until now since the UR9 changes mentioned in the summary below were never released until UR12:


Use the Microsoft Dynamics CRM 2011 Custom Code Validation Tool to identify potential issues with custom JavaScript in JavaScript libraries and HTML web resources. The Microsoft Dynamics CRM Online Q2 2012 Service Update and Microsoft Dynamics CRM 2011 Update Rollup 9 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. The Microsoft Dynamics CRM 2011 Custom Code Validation Tool helps identify potential problems so that a developer can fix them.

Microsoft Dynamics CRM 2011 Custom Code Validation Tool Setup

  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 that 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 CustomCodeValidationToolForMicrosoftDynamicsCRM201_1_0_0_0_managed.zip 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.
Some of the screen shot of the Custom Code Validation Tool












 


These are some fixes I have done.

Earlier version

With Roll-up 12


var xmlHttpRequest = new
ActiveXObject("Msxml2.XMLHTTP");


var xmlHttpRequest = new XMLHttpRequest();


event.returnValue = false;


context.getEventArgs().preventDefault();

IsDirty();

Xrm.Page.data.entity.gsetIsDirty();



crmForm.FormType


Xrm.Page.ui.getFormType()


crmForm.ObjectTypeName


Xrm.Page.data.entity.getEntityName()


The XMLHttpRequest is being created using ActiveX, which is only supported by Internet Explorer.
Simply changing the affected code to the below has fixed the issue and it now works across all browsers.

var xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.open("POST", "/mscrmservices/2007/CrmService.asmx", false);

Note: The change on the second line may not be obvious, but .open has been changed to use a lower case O
This is for Cross Browser Remove these two lines: There is no issue with IE

xmlHttp.setRequestHeader("Content-length", params.length);

xmlHttp.setRequestHeader("Connection", "close");

XMLHttpRequest isn't allowed to set these headers, they are being set automatically by the browser. The reason is that by manipulating these headers you might be able to trick the server into accepting a second request through the same connection, one that wouldn't go through the usual security checks - that would be a security vulnerability in the browser.

subgrid.control


subgrid.control.setParameter("fetchXml", fetchXml); is changed to 
subgrid.control.SetParameter("fetchXml", fetchXml);


same like

subgrid.control.refresh(); to
subgrid.control.Refresh();

All function of subgrid.control will start with capital character

As the name suggests this DOM function is used to access an element of the page and it is used very often by most web developers. However, because the Xrm.Page object model provides the supported way to access form elements, any use of the getElementById function should be examined carefully.
It is fine to use getElementById to access elements in HTML web resources. But if this method is used to access Microsoft CRM application elements, there is no guarantee that the Id attribute value will be the same. When it changes, code that depends on this method to access the Microsoft CRM application elements will be broken. The way to avoid this is to use the Xrm.Page API.
Sri Lanka .NET 
                Forum Member