SSRS escape ampersand for sub report link

juniormint 1 Reputation point
2021-06-29T21:15:09.727+00:00

I have the following code to use to create a new tab for sub reports:
="javascript:void window.open(" &"'"& Globals!ReportServerUrl &"/Pages/ReportViewer.aspx?"&Globals!ReportFolder &"/SRpt_NonInvTransSumBulkDispBalByHauler&CarrierName="&Fields!Carrier_Name.Value &" ','_blank')"

It works well unless I run across a sub report link that contains an "&" i.e. J&B Enterprises.

Can someone please tell me how to escape the ampersand?

Any help will be greatly appreciated!

juniormint

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,813 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Joyzhao-MSFT 15,566 Reputation points
    2021-06-30T02:25:31.247+00:00

    Hi @juniormint ,
    From my research, the effective method is to use Escape Function for javascript. The escape() function was deprecated in JavaScript version 1.5. Use encodeURI() or encodeURIComponent() instead.

    You could refer to the case: SSRS - Opening sub-report in a new window "&" issue.
    Hope this helps.
    Best Regards,
    Joy

    0 comments No comments