Some coding guidelines for Microsoft Dynamics CRM 2013

MS CRM coding guidelines

In general: as you know, client development in Microsoft Dynamics CRM is web development, so everything you know about good web design (technical) matters

  • treat JavaScript as a first class programming language, apply patterns of real life coding and don’t get trapped in the “it is just a little bit scripting” trap
    • use code conventions
    • apply object oriented or functional design principles, whatever applies
    • think in patterns, where applicable (ok, 99% will be observer pattern, I know)
    • apply automated testing where possible (I use because it fits well in the jQuery landscape)
  • use “namespaces” in JavaScript
  • minimize transport of data
    • fetch/upload only really necessary data
    • minify/combine scripts
    • latency matters more than bandwidth
  • use asynchronous request as often as possible
    • think about enabling fields after an asynchronous fetch instead of disabling fields after a synchronous one
    • sometimes, more than one request is necessary for one operation: even they can be made parallel, one only hast to ensure, that every answer is there before continuing with processing ( barrier pattern (well, not really a pattern, more a technique))
    • thinking functional and using the functional aspects of JavaScript helps a lot in making things parallel
  • beware of the fact, that web resources are loaded in parallel, so do not use code from one resource in another while loading, call everything in the onload event
  • try to find a good balance between using a big library (jQuery or knockout or whatever) and setting up small functionality on your own (for example: if you have to parse the search part of your URL, you could use BBQ ( ) or write a regular expression to find what you need.)
  • do not rely on the latest technologies in your browser, MS CRM can serve multiple browsers with multiple versions. I had a fair amount of work to build things back. One pitfall was the use of the window communication in ie8/9/10 – they just behave differently in the versions…
  • do not use relative addresses for loading web resources in CRM 2013, because the forms in Pop Out Mode seems to have another context.
  • Make sure to define the filtering attributes for Plug-Ins. Because CRM uses now the auto save every 30 seconds, they will be triggered frequently.
  • Beware that the HTML Web resources and the IFrames are not re-reloaded and not refreshed after the form changes from Create to Update Mode (CRM 2013).

No comments yet.

Leave a Reply