CRM 2013 New and Beautiful getClientUrl() method instead of getServerUrl()

In CRM 2013 Microsoft has introduced this new client context method called “getClientUrl”

This is the replacement to the previous method called “getServerUrl” that was present in CRM 2011.

This method was faulty because it always returns the server name in the URL as it is set up in the CRM deployment manager, irrespective of how the host url looks like.

this is issue in scenarios where users might have invoked CRM using the server IP address or fully qualified domain name etc.

because when in the java script we call getServerUrl it does not return the URL with the server name as it was used by the calling the host url, but that of what is stored in the server, which fails , in the situations where the server name is not accessible from the host machine but the IP or fully qualified name.

in order to correct this fault in the getServerUrl() method call, Microsoft has introduced this getClientUrl() ,which takes care of the Host URL through which CRM is invoked and return the OData Url accordingly.

Please note getServerUrl() is now deprecated.

the details found in SDK is as below..

getClientUrl

Returns the base URL that was used to access the application.

JScript                                                                        Copy Code
context.getClientUrl()

Use this instead of the deprecated getServerUrl method.

The values returned will resemble those listed in the following table.

Client Value
Microsoft Dynamics CRM (on-premises) http(s)://server/org
Microsoft Dynamics CRM Online https://org.crm.dynamics.com
Microsoft Dynamics CRM for Outlook with Offline Access when offline http://localhost:2525

Return Value

Type: String

Advertisements
This entry was posted in CRM 2011, CRM 2011 Online, CRM 2011 SDK, CRM2013, java script and tagged , , . Bookmark the permalink.

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