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, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
JPHK
Frequent Visitor

User Owns Data App - open report in new window

I've setup the sample user owns data app from Microsoft and all works well. However, rather than loading the report in a container on the same page as the report selection, I want it to load in a new window. I have tried edditing the embed.js file accordingly and while a window loads and the powerbi loading icon displays, the report never loads. Is it possible to make this work?

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @JPHK ,

Please modify your embed.js file as below:

// Get the report details from your application
let reportId = '...';
let embedUrl = '...';
let accessToken = '...';

// Create a new window
let reportWindow = window.open('report.html');

// Wait for the new window to load
reportWindow.onload = function() {
    // Get the Power BI service object
    let powerbi = window.powerbi;

    // Embed configuration used to describe the what and how to embed
    let config = {
        type: 'report',
        tokenType: powerbi.models.TokenType.Embed,
        accessToken: accessToken,
        embedUrl: embedUrl,
        id: reportId,
        permissions: powerbi.models.Permissions.All,
        settings: {
            filterPaneEnabled: true,
            navContentPaneEnabled: true
        }
    };

    // Get a reference to the embedded report HTML element
    let reportContainer = reportWindow.document.getElementById('reportContainer');

    // Embed the report and display it within the div container
    let report = powerbi.embed(reportContainer, config);
};

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @JPHK ,

Please modify your embed.js file as below:

// Get the report details from your application
let reportId = '...';
let embedUrl = '...';
let accessToken = '...';

// Create a new window
let reportWindow = window.open('report.html');

// Wait for the new window to load
reportWindow.onload = function() {
    // Get the Power BI service object
    let powerbi = window.powerbi;

    // Embed configuration used to describe the what and how to embed
    let config = {
        type: 'report',
        tokenType: powerbi.models.TokenType.Embed,
        accessToken: accessToken,
        embedUrl: embedUrl,
        id: reportId,
        permissions: powerbi.models.Permissions.All,
        settings: {
            filterPaneEnabled: true,
            navContentPaneEnabled: true
        }
    };

    // Get a reference to the embedded report HTML element
    let reportContainer = reportWindow.document.getElementById('reportContainer');

    // Embed the report and display it within the div container
    let report = powerbi.embed(reportContainer, config);
};

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Perfect. Thank you very much.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

Top Kudoed Authors