Yesterday I ran into a small problem with adding parameters in a report's URL. All parameters were based on MDX queries. One parameter was for time, and the parameter usually looks like this "[Time].[YMWD].[Month].&[4]&[2007]". When I did a drillthrough directly with "Jump to report", the parameters were sent without problems, even with MDX syntax. When I did "Jump to URL" and added a javascript, the part with "&[4]&[2007]" stopped the report from rendering.
Error message:
The path of the item '/MyReport,[4],[2007]' is not valid. The full path must be less than 260 characters long; other restrictions apply. If the report server is in native mode, the path must start with slash. (rsInvalidItemPath) Get Online Help
After searching a bit, I found a white paper at TechNet called "Implementing Smart Reports with the Microsoft Business Intelligence Platform" by Teo Lachev. The article looked promising until I got to the part about "Implementing Drillthrough Navigation":
"Initially, I was planning to demonstrate the Jump to URL option which gives more flexibility to construct the URL link. For example, assuming that you have an embedded function that sets the reportLink variable to contain the URL address of the Daily Product Sales report, the following URL navigation action would open the report in a new window and resize the window.
"javascript:void(window.open('" & reportLink & "','_blank',
'location=no,toolbar=no,left=100,top=100,height=600,width=800'))"
The problem with URL navigation and OLAP reports is that the parameter values would typically contain ampersand (&), e.g. "[Dato].[Time Index].&[200312]". This presents an issue with the URL addressability option because the Report Server interprets & as a query parameter placeholder.
Even escaping the parameter value (JavaScript escape function or using %26 for &) doesn’t help because Internet Explorer automatically unescapes the value. If someone discovers a workaround for using special characters and URL addressability, please let me know."
Fortunately, Nilesh Unadkat here at Avanade was better at figuring out what to search for than me, and pointed me to this discussion:
http://prologika.com/CS/forums/p/370/1564.aspx
In order to make ampersands (&) work in a URL when used with a javascript, regardless of Reporting Services or MDX, you need to escape it and force it to use &. You do this by replacing the original & with %2526.
Geoff, the guy who posted the solution explains it like this:
Yes the %26 does work for Url addresses in the Jump to URL. %26 goes to & after the parameters are parsed. You need %2526 if you put a javascript routine in the Jump to URL because it gets processed by the browser twice. %2526 goes to %26 goes to &.
So, in order to use Jump to URL when you need to have &s in your URL, you need to do something like this:
="javascript:void(window.open('" & Globals!ReportServerUrl & "/?%MyReport&MyMDXDate=" & replace(Parameters!MyDate.Value, "&", "%2526") & "&rs:Format=PDF'))"
(Teo's example says Date instead of Dato, but Community Server would not let me save it when I used Date. Not quite sure why, though. If you don't want to have it in PDF format, just remove "&rs:Format=PDF".)
(The discussion was found on Teo Lachev's forum, so, the last comment about letting him know about any workarounds has been fullfilled. He's even written a post about it: Ampersands Gone Wild. )