Microsoft Dynamics CRM 2011 – Upgrade Scripts from CRM 4.0 to CRM 2011

When your Microsoft Dynamics CRM 4.0 organization is upgraded, your script customizations will be upgraded to adapt to new features added in Microsoft Dynamics CRM 2011. If you have used only supported script methods you should expect that the full functionality of your scripts should remain intact after the upgrade.

Scripting provides the greatest opportunity to perform unsupported customizations. If requirements have demanded that you use unsupported scripting methods, you should expect that they may not work after your organization is upgraded. You must allocate time and resources to test whether they continue to work after you upgrade and potentially re-implement your customizations to adapt to breaking changes.

You should review your customizations and identify whether you can now achieve equivalent results using new capabilities introduced in Microsoft Dynamics CRM 2011.

This blog provides a general overview of what you should expect for your scripts when your organization is upgraded and provide a description of new capabilities that address requirements that could not typically be achieved by using supported script customizations in Microsoft Dynamics CRM 4.0. This blog doesn’t provide detailed information about how to migrate unsupported script customizations to a working or supported state for Microsoft Dynamics CRM 2011.

Upgrading Scripts that Use crmForm

Microsoft Dynamics CRM 4.0 used the crmForm object to provide access to form fields. The crmForm is deprecated in Microsoft Dynamics CRM 2011. Scripts using crmForm will continue to work in Microsoft Dynamics CRM 2011 to support backward compatibility, but certain Microsoft Dynamics CRM 2011 features cannot be achieved by using crmForm. You should plan to migrate your scripts from using crmForm to Xrm.Page.

If you upgrade scripts from Microsoft Dynamics CRM 4.0 and then prepare or receive an updated solution that contains scripts that are designed to use Xrm.Page and a different naming convention, make sure that you remove the event handlers created during upgrade. Otherwise you could have two event handlers performing the same operations.

Organizations who have added customized scripts in addition to scripts provided by an ISV to their Microsoft Dynamics CRM 4.0 deployment should prepare to separate their custom script logic from the script logic provided by an ISV.

Using JScript Libraries

In Microsoft Dynamics CRM 4.0 form event scripts were embedded within a form. Each event allowed you to add script code to handle it and there was no supported method to re-use code by defining functions or loading JScript library files together with the form.

Microsoft Dynamics CRM 2011 provides for JScript libraries to be defined as Web resources and there is a much more robust event handler pipeline so that multiple event handlers can be associated with any given event. When your organization is upgraded a new JScript library is created for each form. For example, all the scripts for the main account form will be added as functions to a JScript library named account_main.js. The code you have specified for each event is converted into a function and that function is registered as an event handler for the event.

After your organization is upgraded you may want to review the JScript libraries and refactor them so that you can take advantage of any opportunities for code re-use in addition to converting them over to use Xrm.Page methods.

You also can associate JScript libraries to the form without explicitly associating them to a form event. This enables for your event handler functions to use utility functions in these shared libraries.

New Capabilities that Replace Unsupported Methods

The following table highlights new capabilities available using the Xrm.Page that were only possible using unsupported methods in Microsoft Dynamics CRM 4.0. If you have used unsupported methods to achieve these results you should plan to changes your scripts so that they use these supported methods after you upgrade:

Goal: Manipulate views presented for a lookup field.
Xrm.Page method: Xrm.Page.ui.addCustomView, Xrm.Page.ui.setDefaultView

Goal: Change the labels that appear in the form.
Xrm.Page method: Use the setLabel method for tabs, sections, controls and navigation items.

Goal: Hide form elements.
Xrm.Page method: Use the setVisible method for tabs, sections, controls and navigation items. You can use the setDisplayState method to expand or collapse a tab.

Goal: Set focus on a form tab or navigation area.
Xrm.Page method: Use the setFocus method.

Goal: Set the required level for controls.
Xrm.Page method: Use the attribute.setRequiredLevel method.

Goal: Add additional functions to an event using code.
Xrm.Page method: Use the attribute.addOnChange or entity.addOnSave methods.

Goal: Hiding menu items or buttons.
Xrm.Page method: The only capability within Xrm.Page to affect the ribbon is to use the refreshRibbon method. To hide or disable controls present in the ribbon you must configure <EnableRule> (RibbonDiffXml) and <DisplayRule> (RibbonDiffXml) within <CommandDefinition> (RibbonDiffXml) elements. These rules allow for a number of data-driven rules you can apply to hide or disable controls for a form. If your logic requires data that is not available from any of the rule elements provided you can create a <CustomRule> (RibbonDiffXml) that will call a function in a JScript Library.

New URL for Addressable Forms and Views

As described in URL Addressable Forms and Views the format of URLs used in Microsoft Dynamics CRM 2011 has changed. To open a new account from in Microsoft Dynamics CRM 4.0 you would use the relative URL /SFA/accts/edit.aspx. In Microsoft Dynamics CRM 2011 you will use /main.aspx?etn=account&pagetype=entityrecord. Your Microsoft Dynamics CRM 4.0 URLs will continue to work in Microsoft Dynamics CRM 2011 but you should plan to migrate them over to use the main.aspx page for future upgrades.

Using Web Services

Any Microsoft Dynamics CRM 4.0 Web service calls you made in scripts should continue to work using the 2007 endpoint. For Microsoft Dynamics CRM 2011 the REST endpoint is much easier to use for basic operations to create, read, update, and retrieve records in script. Although the Xrm.Page.context.getAuthenticationHeader function exists, you should not modify your scripts to use it. Scripts can continue to use the global getAuthenticationHeader function. The Xrm.Page.context.getAuthenticationHeader function is deprecated.

Upgrading ISV.Config Configurations

Custom <Button> and <MenuItem> elements in the ISV.Config for Microsoft Dynamics CRM 4.0 allowed for specifying scripts for actions when the controls are used. During upgrade these scripts are added to JScript Libraries as functions and are migrated to use equivalent Ribbon controls.

Custom <NavBarItem> elements are upgraded so that the form navigations are included in the FormXml in Microsoft Dynamics CRM 2011.

With the capabilities to define custom UI elements removed from ISV.Config, the only remaining functional items remaining in ISV.Config are to specify configurations of the <ServiceManagement> element.

My above blog is based on Microsoft’s Official information.

I hope this blog about ‘Microsoft Dynamics CRM 2011 – Upgrade Scripts from Dynamics CRM 4.0 to Dynamics CRM 2011’ was informative. Please feel free to leave your comments.

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: