Transformer! for Dynamics CRM–In-Depth


Why is it needed?

Well, for some organizations, it may not be.  If the JavaScript you wrote for CRM 4.0 was using supported methods, it will continue to function just fine in CRM 2011.

But, if you used unsupported methods, like hiding and showing fields, sections, tabs, navigation elements, etc., you’ll need to manually refactor that code to make it work properly within CRM 2011.

Also, the JavaScript object model for CRM 2011 has been totally restructured to provide a more robust platform for XRM development.  That restructuring required a totally different and separate object model which gives the JavaScript developer additional functionality.  It also adds support for development practices which were widely used in CRM 4.0, but totally unsupported ( as mentioned above ).

What does it do?

There are four methods available for converting JavaScript from CRM 4.0 to CRM 2011

  • Directly from CRM 4.0
  • From an exported CRM 4.0 customization file
  • From a folder
  • From a single file


When the conversion is finished, you are presented with an interface that looks much like this:


As you can see, you have a side-by-side comparison between your CRM 4.0 JavaScript and the converted CRM 2011 JavaScript.

Here is what happened during the conversion process:

  • JavaScript was converted from the CRM 4.0 object model to that of CRM 2011.  Basically, we convert crmForm to Xrm.Page and align the various CRM 4.0 properties and method to their CRM 2011 counterparts.
  • Unsupported JavaScript is converted into supported JavaScript where ever it is possible.  Things like:
    • Showing and hiding fields
    • Showing and tabs
    • Showing and hiding navigation elements
    • Setting a field’s required attribute
    • just to name a few
  • Any code or practice that may cause issues later is noted not only in the conversion report, but also in the code itself.

 It should also be noted that the entire conversion process for this sample organization took less than 30 seconds.

How does it work?

This is not a search and replace ( or destroy ) scenario.  We created a JavaScript parser and programmatically convert known code and examine defined problem areas in order to generate the cleanest possible conversion.  Is it perfect?  Probably not – since JavaScript can be written in an unlimited number of ways, and you can’t account for all of the scenarios you might find.  But, we come really close and if you run into a conversion issue, we have a feedback form for you to share your problem with us so that we can get it corrected distribute the update to everyone else.

Can you show me an example?

You bet.  Here is a simple function that takes the first name and last name of a Contact and places them into a custom field called new_salutation.

CRM 4.0

BuildEnvelopeSalutation = function()
    var firstname = crmForm.all.firstname.DataValue;
    var lastname = crmForm.all.lastname.DataValue;

    var newSalutation = firstname + " " + lastname;

    crmForm.all.new_salutation.DataValue = newSalutation;

CRM 2011

BuildEnvelopeSalutation = function()
    var firstname = Xrm.Page.getAttribute("firstname").getValue();
    var lastname = Xrm.Page.getAttribute("lastname").getValue();

    var newSalutation = firstname + " " + lastname;


How about another example?  Maybe something from the not-supported side of the house?  Try this:

CRM 4.0 = ""; = ""; = ""; = "";

CRM 2011

/* CONVERSION ALERT */Xrm.Page.getControl("totalcampaignactivityactualcost_c").setVisible(true);
/* CONVERSION ALERT */Xrm.Page.getControl("totalcampaignactivityactualcost_d").setVisible(true);
/* CONVERSION ALERT */Xrm.Page.getControl("budgetedcost_c").setVisible(true);
/* CONVERSION ALERT */Xrm.Page.getControl("budgetedcost_d").setVisible(true);

As you can see, we’re converting the setting of a style which will show a hidden field in CRM 4.0 to the a fully-support method to set the visibility in CRM 2011.  You’ll also notice the Conversion Alert comments.  Those were inserted because the developer is using partial field names which are not needed in CRM 2011 ( they are also listed on the conversion report, don’t forget ).

Additional Functionality

The end-product of the conversion process is a Visual Studio 2010 solution that contains both the CRM 4.0 JavaScript and the CRM 2011 JavaScript.  You can review the converted code using the Migration Assistant interface or open the project in Visual Studio.

During the conversion process, we also extract relevant information that may help you during the conversion process:

  • List of all attributes found in use during the conversion
  • List of all user-defined functions
  • List of instances where ActiveX controls are used
  • Any conversion issues
  • The location where the object was found
    • Entity
    • Attribute
    • Event
    • Tab
    • Section

Here’s a screen shot of a sample conversion report:


Uploading the Converted JavaScript into CRM 2011

The CRM Migration Assistant 1.1 allows you to upload the converted JavaScript into CRM 2011 directly. It automatically handles the tasks of creating JavaScript Web Resources and modifying the main data entry form so that the converted code is used instead of the original JavaScript.