cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gotters
Helper I
Helper I

saveAsTriggered not firing for Save As in Embedded

The SaveAsTriggered event is not firing for me when embedding a report.

 

Even in the playground I cant get it to fire.

Is there something obvious that I am missing?

 

Try the following code in playground:

https://playground.powerbi.com/en-us/dev-sandbox

 

// Embed a Power BI report in the given HTML element with the given configurations
// Read more about how to embed a Power BI report in your application here: https://go.microsoft.com/fwlink/?linkid=2153590
function embedPowerBIReport() {
/*-----------------------------------------------------------------------------------+
| Don't change these values here: access token, embed URL and report ID. |
| To make changes to these values: |
| 1. Save any other code changes to a text editor, as these will be lost. |
| 2. Select 'Start over' from the ribbon. |
| 3. Select a report or use an embed token. |
+-----------------------------------------------------------------------------------*/
// Read embed application token
let accessToken = EMBED_ACCESS_TOKEN;

// Read embed URL
let embedUrl = EMBED_URL;

// Read report Id
let embedReportId = REPORT_ID;

// Read embed type from radio
let tokenType = TOKEN_TYPE;

// We give All permissions to demonstrate switching between View and Edit mode and saving report.
let permissions = models.Permissions.All;

// Create the embed configuration object for the report
// For more information see https://go.microsoft.com/fwlink/?linkid=2153590
let config = {
type: 'report',
tokenType: tokenType == '0' ? models.TokenType.Aad : models.TokenType.Embed,
accessToken: accessToken,
embedUrl: embedUrl,
id: embedReportId,
permissions: permissions,
settings: {
panes: {
filters: {
visible: true
},
pageNavigation: {
visible: true
}
}
}
};

// Get a reference to the embedded report HTML element
let embedContainer = $('#embedContainer')[0];

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

// report.off removes all event handlers for a specific event
report.off("loaded");

// report.on will add an event handler
report.on("loaded", function () {
loadedResolve();
report.off("loaded");
});

// report.off removes all event handlers for a specific event
report.off("error");

report.on("error", function (event) {
console.log(event.detail);
});

// report.off removes all event handlers for a specific event
report.off("rendered");

// report.on will add an event handler
report.on("rendered", function () {
renderedResolve();
report.off("rendered");
});
}

embedPowerBIReport();
await reportLoaded;

// Insert here the code you want to run after the report is loaded

await reportRendered;

// Switch to edit mode.
report.switchMode("edit");

// Insert here the code you want to run after the report is rendered
// report.off removes all event handlers for a specific event
report.off("saveAsTriggered");

// report.on will add an event listener.
report.on("saveAsTriggered", function (event) {
console.log(event);
});

// Select Run and then select SaveAs.
// You should see an entry in the Log window.

console.log("Select SaveAs to see events in Log window.");
1 ACCEPTED SOLUTION
gotters
Helper I
Helper I

Figured it out. I needed to modify the embed config to include
settings: {
useCustomSaveAsDialog: true
}

Then you do need to use your own Save As Modal but then at least the saveAsTriggered will fire!

View solution in original post

2 REPLIES 2
gotters
Helper I
Helper I

Figured it out. I needed to modify the embed config to include
settings: {
useCustomSaveAsDialog: true
}

Then you do need to use your own Save As Modal but then at least the saveAsTriggered will fire!

Hi @gotters ,

 

I am so glad that you could solve your issue by yourself. Please kindly Accept your workaround as the solution. More people will benefit from it. 

 

Best Regards,
Rico Zhou

 

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

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

BizApps LATAM 2023

Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

Power Platform Bootcamp

Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.