Please wait, loading...

 

Get Server URL or IP using JavaScript in MSCRM 2011 , MSCRM 2013 , MSCRM 2015

June 10, 2015
Some time we need to get server IP  instead of Server URL Like when we need to write Odata Query in dev and frequently sift Solution from dev to production , it imp to get Ip dynamically so , you Odata don’t give error .
// Simple Server Url using JavaScript
var serverUrl = Xrm.Page.context.getServerUrl();
//Work fine for both IP And server

var serverUrl = document.location.protocol + “//” + document.location.host + “/” + Xrm.Page.context.getOrgUniqueName();

This Above code will work fine for both Server IP or Url as when we access mscrm record with only server name ( but our odata code contain ip it will throw an exception ) or if we access with IP ans our code contain server url so to prevent this we can use above code to get dynamic URL address.

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