Currently, I have two different methods to decide which version of CRM that my JS runs on. The addresses are similar but differ still, depending on whether it's on-line or on-premise. I've tried to integrate them but it's still depending on a variable as the code below shows. What would be a neater solution (one that will pick the right URL to the service for organization data)?
var isOnLine = true;
var organizationName = Xrm.Page.context.getOrgUniqueName();
var organizationUrl
= "http" + (isOnLine ? "s" : "") + "://"
+ parent.window.location.host
+ (isOnLine ? "" : "/" + organizationName)
+ "/XRMServices/2011/OrganizationData.svc";
Most of all, I'd like a method of obtaining the service's URL by a call to something (not sure what, though). If it's not possible, I'd like to be suggested a method of detecting if the currently run script is deployed in on-line or on-premise installation.
It's also of some importance that the method (if any available) will work independently of the version (or at the very least that it checks using if statement what version that is the currently run).