Blog

Upgrading Microsoft Dynamics CRM Extensions Pt. 2 – Javascript Upgrades

With Customers upgrading from Microsoft Dynamics CRM 2011, Beringer has been tasked with providing infrastructure software upgrades to advance CRM as well as the surrounding software extensions that interact with it. A common CRM extension we offer is Javascript customizations that interact with entity forms. When upgrading from CRM 2011, there are some parts that need to be updated due to deprecated Javascript functions.

In this multi-part blog series, I will cover some steps we took to upgrade our CRM extensions to interact with CRM 2013 and CRM 2015. This article will discuss upgrading the Javascript functions that operate on a Form. In my previous blog, I discussed upgrading the Installshied extension. You read about it here.

GetServerUrl() -> GetClientUrl() Method

Microsoft with UR 12 of CRM 2011 deprecated the getServerUrl() method for a getClientUrl(). The getServerUrl method in Javascript returns the base server URL depending on whether the user is connected via CRM On-premise, CRM Online, or Microsoft Office Outlook. getClientUrl() also retrieves the access URL, however there is a slight difference outlined below in Microsoft’s Documentation:

“The URL returned is the standard URL used to access the application. If you access the server locally using http://localhost or use an IP address instead of the actual name of the server, this will not be reflected in the value returned by this function. This means that if you are making web service calls or accessing web resources, the browser will apply security settings that apply to requests that cross domains. To avoid this, always connect to Microsoft Dynamics CRM using the getClientUrl method..”

From <https://msdn.microsoft.com/library/gg334511(v=crm.5).aspx>

The getClientUrl() method takes the local server or IP address scenarios into account, so to ensure your customizations have the necessary permissions, you will have to use the getClientUrl() function

SDK.REST

REST and Odata calls are a neat way for your Javascript scripts to retrieve data from the CRM Web API. However, the libraries necessary to perform these methods need to be upgraded if you are using the files from the CRM 2011 SDK.

The root cause is the getServerUrl() function mentioned above. This method will not operate in CRM 2015 as it is deprecated, so you will need to update your SDK.REST library with files from the CRM 2015 SDK.

Its also important to note that SDK.REST.js companion script, json2.js, is not necessary for using REST calls in CRM 2015

crm.Form

The crm.Form object that was used in CRM 4 was supported in CRM 2011 until UR 12, so it’s possible that your CRM system still utilizes this code. This object has been replaced by the Xrm.Page object for CRM 2011 to CRM 2015. There are many functions in the Xrm.Page Reference page that easily replace the crm.Form object.

Thanks for reading, there are some resources below for upgrading your Javascript code for your next CRM upgrade. If you have questions on the content in this article, please feel free to contact Beringer. Beringer is a Microsoft Gold Certified Partner who provide expertise in your implementation of Microsoft Dynamics CRM.

References

CRM 2015 SDK for updated SDK.REST Libraries:

http://www.microsoft.com/en-us/download/details.aspx?id=44567

Xrm.Page Reference

https://msdn.microsoft.com/en-us/library/dn481607.aspx

Deprecated Features from CRM UR 12

https://msdn.microsoft.com/en-us/library/gg509046.aspx#BKMK_FeaturesRemoved