Custom AJAX function in SSRS report

Zolotoy 221 Reputation points

I am trying to create a custom function that would do an AJAX call.
Here is the function:
Public Function getImage(ByVal s As String) As String
Dim objHTTP = CreateObject("XMLHttpRequest")
'Dim URL = ""
'objHTTP.Open("POST", URL)
End Function

I call this function in a textbox expression like this:

I am getting #error in place of the textbox while running it in the Builder and on the server. If I comment all code in the function then no error.

Any idea how to fix it?


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,788 questions
0 comments No comments
{count} votes

Accepted answer
  1. Lukas Yu -MSFT 5,816 Reputation points


    Within my experience, this is the only way that I've seen to run a JS code, in the Action function of an item.

    It is a called event in the report. I've not found other way to run the JavaScript in SSRS to work like AJAX function.

    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Lukas Yu -MSFT 5,816 Reputation points


    The AJAX function won't working, because that the custom code is "seen" and processed in SSRS server.

    The browser only received the processed data , and present it.

    For example, I add some code in the report to do some string operation.

    The browser could only receive the processed results see:

    It is only a div, no code being passed to the browser.

    AJAX code spinet need to be placed in the script session of the HTML page before the web page being rendered by the browser.

    This is why it is not working in SSRS.

    There is no work around for this , if we only place the code in report Custom Code session.


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    What can I do if my transaction log is full?--- Hot issues November
    How to convert Profiler trace into a SQL Server table -- Hot issues November

    0 comments No comments

  2. Zolotoy 221 Reputation points

    So, if I add a function to the ReportViewer.aspx I can use it in my report?

    0 comments No comments

  3. Lukas Yu -MSFT 5,816 Reputation points


    It is not suggested to change the official web portal of SSRS. I've not personally tried this, I am afraid this would not work neither.
    Also, even if we add it to the web portal it will change the site behavior for all reports.

    0 comments No comments

  4. Zolotoy 221 Reputation points

    I am using this as a textbox expression:

    It's not working. The same code only works when it's used in Action.

    Any other idea how to run JS code when a report is running?

    0 comments No comments