JavaScript Upgrade Strategy #4: Reorganize your functions

Here is a fairly typical view of the function tree of a Dynamics CRM 4.0 organization for the Account entity:




As you can see, we have our OnLoad function with various functions embedded within it.  This was done so that those functions would be available later, to other functions, such as the OnChange events.

After we upgrade to Dynamics CRM 2011, one of the first things that we need to do is to flatten our function hierarchy so that all of the functions are at the same level (in most cases), and you end up with a function tree that looks  like this:




This is done in preparation for consolidating and cleaning up our JavaScript.  Unfortunately, this process is extremely manual and there is not an automated tool to help.

The good news is that while performing this operation, you can really get a good feel for how your code is organized and start to see patterns where you can eliminate redundancy.

We will talk more about JavaScript web resource organization in our next discussion and code consolidation in the discussion after that.

Leave a Reply 0 comments