Wednesday, 23 January 2019

How to get Server URL in JS for D365

How to get Server URL using JS for D365



Please use the below script to find the server URL in JavaScript.


function checkURL()
{
var url ;

if(Xrm.Page.context.getClientUrl)     //Post UR 12

{
    url = Xrm.Page.context.getClientUrl();   // For 2016/D365
}

else      //Pre UR 12

{
    url = Xrm.Page.context.getServerUrl();   // For CRM 2011/2013/2015
}
}