Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
aarshps
Frequent Visitor

Pass value to the embedded app from custom visual

Hi all,

 

I want to pass values to the embedded app from the custom visual used in my report. For eg. I want to raise an event when a click event occurs inside the custom visual so that I can take necessary actions in my embedding app.

 

For eg. I'll be having different player photos shown in a grid, 2 * 3 grid. So there will be a menu icon besides the photos of each photos. These menu icon are custom visuals. And when I click on these custom visuals, I will try to raise an event, or send a message to the parent window, i.e. the parent app where the page is embedded and take necessary actions in the parent app.

 

Necessary actions might be a popup with the player details like age, speed etc. How can I do this?

15 REPLIES 15
llangholz
Regular Visitor

Hello,

 

I'm looking to acheive something similar within my custom visual. Can anyone please confirm whether or not it is possible to emit a custom message from the visual and have it be consumbed by the embedding application via the window.postMessage mechanism? If it is in fact possible, can anyone provide some tips or pointers on how to acheive this? I've tried the obvious `window.postMessage('my message')` which does not seem to be received by the embedding application. I'm thinking there may be some gotcha's somewhere that I'm not aware of.

 

Thanks in advance for the help!

Anonymous
Not applicable

Hi all ,

I also want to acheive something similar when user click on some button in power bi i want to emit and listen that event in parent window how can we do that?
Can we achieve through postmessage

florianSB
Regular Visitor

Has this problem ever been solved?

We are building a web-app that integrates Power BI reports and we would like to trigger certain actions inside our app depending on what the user clicks or selects, e.g. to show pop-ups with external information or to switch a filter of a non-PowerBI element.

Is this possible @v-viig ?

Our app has a very extensive postMessage interface to communicate with Iframes.

Anonymous
Not applicable

Yes it is easily possible. We had written a custom visual which pushed messages to the parent and the event was caught and actions where taken in the app. Easily possible.

Great! So a simple 'postMessage' from inside a custom visual will arrive in the parent window that embeds the report? I was afraid there might be some layers in between to prevent this.

v-viig
Community Champion
Community Champion

Have you tried window.window.postMessage to send data from ifame into main window?

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

 

 

Tried, but not working. Is there any other solution? Is the sandboxed iframe blocking these events?

v-viig
Community Champion
Community Champion

As far as I know, Power BI doesn't block such events since it's used for communication between main window and other custom visuals.

Can you share the code for furhter debugging?

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Hi,

 

same problem here.

 

In the other thread (link), you were saying that PowerBI uses iframe sandbox, maybe that is why postMessage is not working?

 

Regards,

Anatoliy

Correct. Custom Visuals API loads visuals in an iframe.

 

Why do you want to use postMessage?

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Sorry for the late reply.

 

It is possible to achieve what I was trying to do. What I had in mind is I have a button on my Power BI report. When I click on the button, a popup appears in the application where my Power BI report is embedded. So I wanted the application to recieve an event trigger when the Power BI report button is pressed. This was achieved using a custom visual that I wrote. The visual simply passed a string value to the parent windows so that I was able to recieve the event.

Hi @aarshps , I am trying to accomplish something similar, did you accomplish this with postMessage?  Is it possible to target the embedded application window directly, since the custom visual iFrame is contained first in another report iFrame?  Do you know if it is possible to postMessage from the embedded application to the custom visual? 

Thanks,

-Jared

Did you end up having to use postMessage to accomplish it?

v-viig
Community Champion
Community Champion

Thanks for the details.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

@v-viig Please can you confirm if this is possible? Looks like the sandboxed iframe is intercepting messages between the parent window and the custom visuals, to ensure only a certain list of events are handled.

Is there a way to define custom events for communication between the parent and the custom visuals?

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors