Asked by:
Send a message from SSRS report

Question
-
User1366720210 posted
I am rendering a SSRS report in an iframe on my web page. I am trying to figure out if it's possible to send a message from the report (I have added a new button to the report toolbar). I tried postMessage:
window.postMessage('message', '*');
but could not get it working. The outside world wasn't getting the message. If I tried to specify an url of the iframe the report was rendered in I was getting a cors error.
Is it even possible to do what I am trying to do? Please share any idea.
Thanks
Tuesday, October 17, 2017 1:37 AM
All replies
-
User347430248 posted
Hi samegoldinBu...,
I suggest you to display the message from your webpage.
instead of sending the message from report.
you can try to implement the logic when certain report get opened then web page display the message.
you can try to create a JavaScript function to check URL.
further you can post your code.
we will try to look in to that and try to provide you further suggestion.
Regards
Deepak
Tuesday, October 17, 2017 5:32 AM -
User1366720210 posted
That's not what I am after. Here is a link to my post on SO:
https://stackoverflow.com/questions/46602863/messaging-between-application-and-ssrs-report
Tuesday, October 17, 2017 9:23 AM -
User347430248 posted
Hi samegoldinBu...,
try to check that the event for displaying message get executed or not.
try to debug it and check the flow of the code.
A reference to another window; such a reference may be obtained, for example, using the contentWindow property of an iframe element, the object returned by window.open, or by named or numeric index on Window.frames, if you're trying to start the communication from iframe to parent window then parent is also a valid reference
for detailed information you can refer link below.
try to refer the description may help you to find the issue.
Regards
Deepak
Wednesday, October 18, 2017 5:11 AM -
User1366720210 posted
Ok, here is what I have. I have added the following code to the textbox's action in the report:
="javascript:void(window.postMessage('message', '*'))"
The following is in my main application:
window.addEventListener('message', function (event) {
alert(1);
});When the report is loading into an iFrame I am getting alert box three times. Good news - report is communicating with the main application. Bad news that when I click on my textbox nothing happens.
Seems like a SSRS report is posting messages internally when a navigation to a new page is clicked. Well, no luck.
Wednesday, October 18, 2017 9:13 AM -
User347430248 posted
Hi samegoldinBu,
you can try to use your browser to debug your code.
you can put break point there and check why it is displaying the message 3 times.
you can also try to check any event or function get called or not when you click on textbox.
it will help you to know whether the function have any issue or function itself is not get called.
Regards
Deepak
Wednesday, October 18, 2017 9:48 AM -
User1366720210 posted
I was able to successfully send messages from reports back to the main application. It took a couple of tricks and one of them was to filter out messages that a SSRS report sends internally. I can provide some code, tell me what you need specifically.
Monday, May 28, 2018 11:04 AM