Search code examples
powerbipowerbi-embedded

How to handle promises in user defined functions?


I'm building a .NET application for Power BI embedded.Im getting the following error. I've used the Power BI api to print the pages in the report using event handlers and user defined functions.I'm getting the Pages array as o/p using event handlers but not using user defined functions(promise state as pending) enter image description here

Ive tried using event handlers and using function. Im getting o/p for event handlers but not using function.


Solution

  • Before using the APIs, we must Wait for the component / report to get loaded. In the line 20, You are waiting for report to get rendered and then using the API and you can see the pages in the code and it's not the case with code in line 7 Where you are using API when the report is not even available

    References: https://learn.microsoft.com/javascript/api/overview/powerbi/handle-events