Wednesday, August 15, 2007

Open linked report in new window

Unfortunately, there's no simple way to open linked-report in new browser window. The work-around is to use the URL link, rather than report, however that has couple of issues. (a) you have to specify the location, which is a problem if you have dev/test/live environments (basically you have modify the report for each). (b) passing parameters is possible, but can be tricky in case you're passing complex texts.

Here is detailed solution.

In short:

Non-parameterized Solution
="javascript:void(window.open('http://servername
/ReportServer?%2freportFolder%2freportName&rs:Command=Render'))"



Parameterized Solution
="javascript:void(window.open('http://servername
/ReportServer?
%2freportFolder%2freportName&rs:Command=Render
&MyParam1=" & Fields!MyField.Value & "'))"

Couple things to know:

1) Notice that you have to use "http://server/
ReportServer" and NOT the "http://server/Reports" link!

2) In case your "reportFolder" and "reportName" contain spaces, either leave them there or replace them with "+" (e.g. "My Report" -> "My+Report").

3) Notice the "
&" in parametrized solution - it's safer to use than "+", because it will force string conversion on the parameter value.

4) There are more parameters you can use to modify the way the report is presented. Nice description is in this MSDN article.

No comments: