1

I have several sites with pages with ReportViewer web parts on those pages. All web parts use a central report file (.rdl) in a report document library in a reports site.

I would like these reports to show different data based on which site they are being viewed on.

The sites are :

https://name.company.com/sites/reports
https://name.company.com/sites/site01
https://name.company.com/sites/site02
https://name.company.com/sites/site03
etc.

I would like to be able to have the report "know" that it is on site01, site02, site03, etc at run-time and be able use that information to query the appropriate data from SQL Server.

I have been able to store "site01" in a SharePoint list on site01 , "site02" in a SharePoint list on site02, etc, and pass that in as a Parameter to the web part and that works. But I am looking for way for the report itself to determine it's site/context without passing in information as a parameter through connected web parts.

I know SSRS reports can determine the user that is viewing the reports, I just can't seem to find a way to get the Site name/title/URL without passing it in.

3

Use the Globals!ReportServerUrl variable from within Report Builder:

enter image description here

If you just want the base URL of the site, then remove the _vti_bin bit by using an expression:

=Replace(Globals!ReportServerUrl,"/_vti_bin/ReportServer","")
  • Thanks. I verified it works and also that it works when the report file (.rdl) is stored in a document library on a central site and viewed via a ReportViewer web part on a different site. – lwbecker2 Mar 13 '14 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.