Please wait, loading...

 

Get the CRM Organization URL using javascript in ms crm 2011 , ms crm 2013 , ms crm 2015

December 30, 2014

Retrieve the CRM Organization URL with respect to the current domain name. For example, if you are browsing the CRM instance with IP, then the return value would be like this: http(s)://<IP>/<OrgName>If you are browsing with domain name, it would be like this: http(s)://<DomainName>/<OrgName> 



function GetServerUrlRegExp(location) {
var urlReg = new RegExp(/http[s]?://[0-9.:]+/[^/]+/);
var ServerUrl = Xrm.Page.context.getServerUrl();
if (window.location.href.match(urlReg) != null) {
ServerUrl = window.location.href.match(urlReg).toString();
}
if (ServerUrl.match(//$/)) {
ServerUrl = ServerUrl.substring(0, ServerUrl.length - 1);
}
return ServerUrl;
}


SOURCE : JUST2CODE.IN

Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012

https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/04/Microsoftdynamics365.png?fit=640%2C651
Microsoft Dynamics Community Profile

Learn more