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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
gotters
Helper II
Helper II

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 II
Helper II

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 II
Helper II

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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