Power BI Embedded deleteVisual usage in a layout file

Viewed 164

I am trying to use the await page.deleteVisual("8d0e01e7a860c2e5706d"); command when I layout a report page. This seems logical to me. I am going to place various visuals on the page for a certain group of people. For another group of people I will delete a few other visuals and keep this one. I get the following error:

TypeError: report.deleteVisual is not a function at changeLayout (PQLayout.js:56)

Most of the documentation pages are bare and lacking good examples, but this page doesn't help much for the error: https://docs.microsoft.com/en-us/javascript/api/overview/powerbi/remove-visual

Thanks

1 Answers

deleteVisual is a method provided by the Page object but from the error it seems you are calling it for the report object. You should use page.deleteVisual("VISUAL_GUID") to delete the visual.

deleteVisual is a method of powerbi-report-authoring SDK.

You can refer to the live showcase to understand the usage of this SDK:

  1. Live showcase: Quickly create and personalize visuals
  2. Showcase's source code: https://github.com/microsoft/PowerBI-Embedded-Showcases/tree/main/Quickly%20create%20and%20personalize%20visuals

Docs: https://docs.microsoft.com/en-us/javascript/api/overview/powerbi/remove-visual

Related