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.

image

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

 

Hope this helps!

Advertisements

About Debajit
I am a Dynamics CRM Most Valuable Professional (MVP) with 10 years of experience in Microsoft .NET Technologies and 7 years of dedicated experience in Microsoft Dynamics CRM. I have worked with companies like Microsoft, SanDisk, PwC, TMF Group and have extensive experience of implementing complex CRM solutions from both offshore and client side. Currently the face of XrmForYou.com with significant experience in delivering corporate training on Dynamics CRM and have already delivered multiple projects to client through XrmForYou.com Author of multiple tools on codeplex including the 'Role Based Views' and 'CRM-Sharepoint Metadata manager & Attachment Extractor' which are available for commercial use under XrmForYou.com For consulting/ training, drop me a note at info@xrmforyou.com or visit our website www.xrmforyou.com

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

  1. jayakrishna says:

    Thanx…working perfect

  2. Neo says:

    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();
    else
    return Xrm.Page.context.getServerUrl();

    Can anyone help me?

    Thanks in advance!!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: