I was searching the net the other day to try to find a way to programmatically get the reporting server url from CRM. I thought that there must be some way to find it using the standard CRM webservice and I really looked throught the SDK and all the blogs I could find to see if anyone knew.
Finally I gave up and tried to find some other way to get it and I remembered that it is set in the registry so I wrote some code to get it from there and here it is in all it's simple glory:
RegistryKey regkey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MSCRM");
string reportserver = regkey.GetValue("SQLRSServerURL").ToString();
And it worked but only just since it uses the server name and my VPN connection to the customers environment didn't bother with sending it to me why I have to manually add it to the hosts file.
The host file can be found at the path: C:\WINDOWS\system32\drivers\etc\hosts
and I added the row:
Now my button which point to my aspx that redirects to a the report in pdf-format works just fine and is independant of the CRM server it is installed on.
The solution isn't supported as far as I know since you never know if they might change the registry value in the future (not very likely in an update but might happen in an upgrade). If anyone has any supported way of getting this URL, please comment this post.
Microsoft Dynamics CRM Architect