Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open SSRS URL in New Window

I have a report that passes an id that is used to access salesforce.com. I want to open SFDC as a new page from the URL hyperlink. However, nothing I do seems to be working!

="javascript:void(window.open('https://na5.salesforce.com/& Fields!id.Value,'_blank'))"

Fields!id!Value is the SFDC id that is being passed. I'm trying this in the expression to no avail!

I know it is something VERY simple but I'm just not finding it. Thanks in advance for the assistance!

UPDATE!!!

Figured it out!!! For the record, the syntax is:

="javascript:void(window.open('https://na5.salesforce.com/" & Fields!id.Value & "'))"

like image 389
Keith Johnson Avatar asked Aug 01 '13 19:08

Keith Johnson


People also ask

How do I find the SSRS report server URL?

To start The Web Portal By default, the URL is https://<serverName>/reports . You can use the Reporting Services Configuration tool to confirm the server name and URL. For more information about URLs used in Reporting Services, see Configure Report Server URLs (Report Server Configuration Manager).


3 Answers

For the record, the problem with your original syntax was that you were trying to go from referencing an SSRS field to entering a string without separating the two properly. If you wanted your previous syntax to work (without removing the target window's name (i.e., '_blank'), you would do it like this:

="javascript:void(window.open('https://na5.salesforce.com/" & Fields!id.Value & "','_blank'))"

I struggled with this for a long time, but you can make these pretty complex as long as you're careful to put everything together correctly. You can also add multiple javascript commands (but no functions) in the same action expression. Below is one of my most complicated SSRS Go-to-URL Action commands:

="Javascript:" 
    & IIF(left(Fields!Name.Value,11)="RESTRICTED-", 
        "alert('Restricted!'); ","") & IIF(Fields!Name_Alert.Value = 1, "alert('Alternate Alert!'); ","") 
    & "void(window.open('" 
    & Globals!ReportServerUrl 
    & "/Pages/ReportViewer.aspx?%2fJPD%2fPO_Dashboard%2fJuvenile_Profile&rs:Command=Render" 
    & "&rc:Parameters=true" 
    & "&Emp_Number=" 
    & Parameters!Param1.Value 
    & “&ID=" & Fields!ID.Value & "'));"

The key is to make sure that any and all necessary single quotes required by javascript show up inside a string (i.e., "'").

like image 128
Christopher Brown Avatar answered Oct 22 '22 01:10

Christopher Brown


Nonono, don't use ="javascript:void(window.open(.
First, it breaks PDF & Excel reports,
and second, it doesn't work in IE11 and possible also < 11.
Tested it, worked only in Chrome for me.
And third, it's a mess to put it together.

There's a far easier & better solution:
Add &rc:LinkTarget=_blank to your report access URL, like:

https://your-domain.com/ReportServer/Pages/ReportViewer.aspx?%2fJPD%2fPO_Dashboard%2fJuvenile_Profile&rs:Command=Render&rc:LinkTarget=_blank 

and it will open in a new window tab.

Edit:
If you want to make your own display page:

This is how you get all reports:

USE [ReportServer$MSSQL_2008_R2]

SELECT 
     [ItemID]
    ,[Path]
    ,[Name]
    ,[ParentID]
FROM [Catalog]
WHERE Type = 2

And this is how you can display all folders/reports at level x

;WITH CTE AS 
(
    SELECT 
         [ItemID]
        ,[Path]
        ,[Name]
        ,[ParentID]
        ,0 AS lvl
        ,CAST([Name] AS nvarchar(MAX)) AS RecursivePath 
     FROM [Catalog] 
     WHERE [ParentID] IS NULL 


     UNION ALL 

     SELECT 
         [Catalog].[ItemID]
        ,[Catalog].[Path]
        ,[Catalog].[Name]
        ,[Catalog].[ParentID] 
        ,cte.lvl +1 AS lvl
        ,CAST(cte.RecursivePath + '/' + [Catalog].[Name] AS nvarchar(MAX)) AS RecursivePath 
     FROM CTE 
     INNER JOIN [Catalog]
        ON [Catalog].ParentID = CTE.ItemID 



) 

SELECT * FROM CTE 
WHERE lvl = 1 
ORDER BY lvl, Path 

If you only want the folders:

WHERE Type = 1

If you only want the data-sources:

WHERE Type = 5
like image 8
Stefan Steiger Avatar answered Oct 22 '22 01:10

Stefan Steiger


If you are wanting to link to an external URL and want the links to work both within the report viewer and if you export to Excel for example, I use the following expression.

=IIF(
  Globals!RenderFormat.Name = "RPL",
 "javascript:void(window.open('http://www.domain.com/page/" & Fields!Page_ID.Value & "','_blank'))",
  "http://www.domain.com/page/" & Fields!Page_ID.Value
)

It will use the JavaScript if viewing from within the report in the browser and standard linking otherwise.

like image 4
Danny Cullen Avatar answered Oct 22 '22 03:10

Danny Cullen