简体   繁体   中英

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 & "'))"

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 (ie, '_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 (ie, "'").

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 newwindowtab.

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

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.

Here is what I had used; it will open the ChildReport in a new tab, with a parameter voucher_id and its value passed from a dataset.

="javascript:void window.open(" &"'"& Globals!ReportServerUrl &"/Pages/ReportViewer.aspx?"&Globals!ReportFolder &"/JournalVoucher&voucher_id="&Fields!account_voucher_id.Value &" ','_blank')"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM