Error with Xrm.Page.context.getServerUrl() in CRM 2015

Recently we have upgraded our client environment to CRM 2015 and our first observation after upgrade was that none of SDK calls through the custom javascript methods was working. After debugging, we found that there was some common function to get the server url and it was getting it through Xrm.Page.context.getServerUrl().

Although getServerUrl() was already deprecated in CRM 2013 but still it used to work when upgraded from CRM 2011 to 2013. Now it seems to have been excluded from the API list only and hence you would get undefined error if your existing code is using the same. Please check for the list of method it is showing up in the chrome debugger in the Xrm.Page.context namespace, in the below screenshot. You would find that the getServerUrl() method is missing.


changing the code to use Xrm.Page.context.getClientUrl() would work.


Hope this helps!


5 thoughts on “Error with Xrm.Page.context.getServerUrl() in CRM 2015”

  1. Is there a chance for Xrm.Page.context.getClientUrl() to return null or undefined???

    Here is the code i am trying to update:

    if (typeof(Xrm.Page.context.getClientUrl) != “undefined”)
    return Xrm.Page.context.getClientUrl();
    return Xrm.Page.context.getServerUrl();

    Can anyone help me?

    Thanks in advance!!!!

Leave a Reply