UR12 – Upgrading Unsupported Code

Posted by on January 3, 2013  |  commentsComments (0)

When Dynamics CRM 2011 was released, it shipped with a robust JavaScript API. This API is well documented in the SDK and includes methods that cover 90% of what you might need to accomplish when writing custom script in CRM. However, there are still times when you need to write unsupported script, accessing undocumented methods that are defined within CRM’s JavaScript files.

The reason these methods are considered unsupported is because they are intended to only be used internally by native CRM code. There is no guarantee these functions will stay the same through the different versions of CRM, and so using them can end up introducing bugs into your code when you upgrade to a newer version of CRM.

I recently discovered some unsupported code I was using that broke when I upgraded to UR12, and I thought it was worth sharing. I had written code to open the native CRM lookup dialog window (the window that opens when you click the magnifying glass on a lookup), and then do something with the selected record. Before UR12, the lookup window would return an object with an items collection, and that items collection would contain an array of the selected records.

clip_image002

However, I discovered in UR12 that this modal dialog (and, as far as I know, all modal dialogs) now return a JSON string that needs to be parsed into an object. You can see from the screen shot below that the selectedRecords value is now a string (as opposed to the previous screen shot, where selectedRecords is an object). By passing the string into JSON.parse, we can convert the string into the same object that we were using pre-UR12.

clip_image004

Thankfully, this is one instance where updating unsupported code was a fairly simple fix. As a general rule, you should never call unsupported code unless it’s a last resort. The more unsupported code you have, the more likely it is to break when upgrading CRM versions, especially when upgrading to UR12.

Comments

Post a Comment

  • *Required

Contact Us for a Quote, or Personalized Demonstrationof Microsoft Dynamics CRM for Your Business.

Contact Us