-
Notifications
You must be signed in to change notification settings - Fork 475
Create and Edit Report in Embed View
Power BI Embedded reports can now be created from a dataset in your own application.
Relevant access token needed to create new report.
Token should have the following scopes: "Dataset.Read Workspace.Report.Create".
Find full article in Microsoft Docs
var embedCreateConfiguration = {
accessToken: 'eyJ0eXAiO...Qron7qYpY9MI',
embedUrl: 'https://embedded.powerbi.com/ReportEmbed',
datasetId: '5dac7a4a-4452-46b3-99f6-a25915e0fe55',
};
// Grab the reference to the div HTML element that will host the report
var reportContainer = $('#reportContainer')[0];
// Create report
var report = powerbi.createReport(reportContainer, embedCreateConfiguration);
The report will not actually be created until you call the save as operation. This can be done from file menu or from JavaScript.
var saveAsParameters = {
name: "newReport"
};
// SaveAs report
report.saveAs(saveAsParameters);
A new report is created only after save as is called. After you save, the canvas will still show the dataset in edit mode and not the report. You will need to reload the new report like you would any other report.
In order to interact with the new report you need to embed it in the same way the application embeds a regular report, meaning, a new token must be issued specifically for the new report and then call the embed method.
var embedConfiguration = {
accessToken: 'eyJ0eXAiO...Qron7qYpY9MJ',
embedUrl: 'https://embedded.powerbi.com/ReportEmbed',
reportId: '5dac7a4a-4452-46b3-99f6-a25915e0fe54',
viewMode: 'edit'
};
// Grab the reference to the div HTML element that will host the report
var reportContainer = $('#reportContainer')[0];
// Embed report
var report = powerbi.embed(reportContainer, embedConfiguration);
Find full article in Microsoft Docs
call report.save to save user changes. Works if you
await report.save();
Call report.isSaved to check if the report is saved. Using this method can help customers to avoid losing unsaved changes.
bool isSaved = await report.isSaved();