PowerObjects Blog 

for Microsoft Business Applications

|

Xrm.Page.context Unsupported Methods in CRM 2013

Post Author: Joe D365 |

JavaScript comes in very handy when working within Microsoft Dynamics CRM, and we have a lot of blogs on using JavaScript in CRM.

Starting from CRM 2011 UR 12, the getServerUrl (which returns the base server URL) and the getAuthenticationHeader method that was available pre-UR12 when referencing the Xrm.Page.context have been deprecated. These two methods are no longer supported in CRM 2013. So if you are referencing the getServerUrl and you are on UR12, and you are upgrading to UR12 or CRM 2013, you need to change all your JavaScript code to use getClientUrl instead.

A good way to make the JavaScript Version agnostic would be to check if the getClientUrl exists before using it.

For example:

var url ;
if(Xrm.Page.context.getClientUrl)//Post UR 12
{
    url = Xrm.Page.context.getClientUrl();
}
else//Pre UR 12
{
    url = Xrm.Page.context.getServerUrl();
}

Take note that getClientUrl does not append the slash character ('/') at the end of the URL.

So if you are currently using any JavaScript similar to the snippet below…

var serviceUrl = url + "XRMServices/2011/OrganizationData.svc/";

….make sure you change it to:

var serviceUrl = url + "/XRMServices/2011/OrganizationData.svc/";

If this was helpful, you can also check out our other blogs and resources for Microsoft Dynamics CRM 2013.

Happy CRM'ing!

Joe CRM
By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

3 comments on “Xrm.Page.context Unsupported Methods in CRM 2013”

  1. Hi,

    I have written the JavaScript code for crm 2011, but after crm up-gradation to 2013, that code not working in crm 2013.

    so i need to change below code:

    document.getElementById("new_product").setAttribute("lookupstyle", "multi");

    Can anyone help on this.

    Thanks in advance

PowerObjects Recommends