Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
126 views
in Technique[技术] by (71.8m points)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...