Search this blog

Friday, July 10, 2009

Provide a Hyperlink to open in new window in SSRS Report

In SQL Server Reporting Services (SSRS) Report, we can provide Hyperlink field for a report field by following steps,

  • Right Click on the Report Field à Select "Property"

  • Go To "Navigation" Tab from Property window

  • In "Hyperlink action" section à select "Jump to URL" option

  • Enter the URL, For Example http://blog-mstechnology.blogspot.com/

  • Click on "Ok" to apply.

  • Now see the Report output thru Preview Tab in Report Designer.

  • Format the Report Field with fore color and underline (Ctrl + U), if not looks like Hyperlink.
This is general way to provide a hyperlink in SSRS. If you access this link on runtime, it always opens in same window. If you want to open in new window, then you can implement this thru JavaScript as given below

Place the following code on "Jump to URL" section.

="javascript:void(window.open('
http://blog-mstechnology.blogspot.com/','_blank'))"

Then it will open in new window. Hope it helps you.

9 comments:

  1. The unfortunate part on using the JavaScript popup link within a SQL report is that it won't work outside the actual report. If the report is sent via email or pasted into another document the JavaScript will not launch the linked page. See KB article from Microsoft:
    http://support.microsoft.com/kb/885755

    I'm still working on finding a good solution for this with my current report.

    ReplyDelete
  2. Very useful info - thanks!

    ReplyDelete
  3. After exporting the report to PDF - the hyperlink "hand" appears and a trusted source message tries to retrieve the link but fails with an unspecified error.
    Using IE8, Foxit PDF Reader, SSRS 2008, VS2008

    Any ideas on why this would fail via a PDF document?

    ReplyDelete
  4. Same happens when exported to Word (2007)

    ReplyDelete
  5. Exactly what I was looking for,
    thanks

    ReplyDelete
  6. I am also facing the same problem. In the first report I am showing a list of numbers in a table column and for the cell I specified jump to report which launches another report based on this number. In report preview I am able to navigate to the next report, however, when the first report is rendered in PDF, the click function is seems not working and I am not able to navigate to the next report.

    Plz help...
    Raghu

    ReplyDelete
  7. Re: the issue of changing behaviour between rendering formats. In SSRS 2008 R2 there is a new global variable "RenderFormat" that you can use to determine whether the report is being generated for web viewing or PDF (or other formats for that matter). You could use this to selectively change the URL to be a plain link, or encapsulated in the javascript wrapper.

    Hope this helps.

    Cheers,
    Alan

    ReplyDelete
  8. Good one..!
    But the properties of the window opened from SSRS hyperlink is different than CRM window properties like width=750,height=500,toolbar=no,menubar=no, etc. How can we set thees properties to this window.?

    ReplyDelete
  9. Thanks to Alan, Anonymous December 5, 2010 at 12:14 PM
    That global variable is awesome, I was able to do exactly what you said. Just for anyone looking for this in future, the action on a link was an expression like this:

    =iif(Globals!RenderFormat.IsInteractive = "TRUE","javascript:void(window.open('"& Fields!URL.Value & "'));", Fields!URL.Value)

    This meant that in an Excel/PDF export, the link would be directly to the URL, whilst in the browser, the link would be wrapped in a javascript command.

    ReplyDelete