Dear Community,
I am using a Code Component in PowerApps which is developed using PowerApps Component Framework (PCF) to embed Power BI report. By default PCF provides the following methods which automatically get invoked when interacting through PowerApp:
Now, I have different Report tiles in my PowerApp. So, when user click on a particular tile, the Report Metadata is passed to PCF component based on which report is loaded.
But in the FIRST attempt, reports failed to load (updateView() in PCF Component is not called). But for all subsequent times, reports get loaded as expected (updateView() in PCF component called).
Can someone give an idea/ suggestion/ workaround/ different Approaches to address this issue?
Thanks.
Hi @Anonymous.. I understand that you are trying to load a dataset when updateView() is getting called.. Yea this could be called multiple times and your dataset might still be loading which might possibly through an error.
But in my case, I am not using any dataset load operation.. nor i have used any "async" in my code. Problem for me is "updateView()" itself isn't getting called in the first load. And for all subsequent loads, updateView() called 4 times as you have said and everything works fine. Do you have any idea why updateView() isn't triggered? or can you suggest any alternate ways to resolve this issue..
Thanks, Surya
Hi @cchannon. My PCF component hits init() everytime i load it. But it doesn't call updateView() even once during the first load. I have tried firing updateView() manually in init() and it called the updateView too.. but i couldn't embed report by manually triggering it. In Test Environment everything works fine.
I am suspecting that updateView() must be triggered in-order for the PCF control to get the latest content through context. But this is not happening in the first load. All subsequent loads, updateView() is called 4 times as you have already mentioned this updateView() executes in a row multiple times at once to reflect the latest values.
In my experience, I have faced this error for (at least)two scenarios:
1. When using dataset type PCF, the dataset may not correct loading at first, if you put some log on update view you will see multiple times of loading, but not always with correct data. The solution is to add some check on update view:
if (context.parameters.gridDataSet.error) {
// console.log("dataset load error, reloading");
context.parameters.gridDataSet.refresh();
return;
}
if (context.parameters.gridDataSet.loading) {
// console.log("dataset is loading, wait.");
return;
}
2. The other time I remember is that some guy used 'async' in init or updateview, which caused the event flow all ruined when control loading. After we removed the async and make init and updateview sync(with promises to render control), the error is gone.
Hope these will help.
OK, so does the same "never hits Init() on the first load" problem also happen in the test environment? I am guessing it doesn't. If you never hit Init() then something must be failing before your PCF tries to load. Is there other script on the page? other PCFs that might be throwing their own errors? Web resources that could be causing problems?
Hi, Can anyone please help me on this issue i am facing. Any reply would be appreciated. Thanks, Surya
Hi @cchannon I am sure that UpdateView() in PCF isn't getting called not even once in the first attempt when i try to load the screen in the play mode. Why is this happening.. Any idea?
In the PowerApps Component Framework Test Environment, even though when I am trying to embed report using the PowerBI functions, it doesn't load. Only when this UpdateView() executes and calls the PowerBI functions, then only report is loaded properly.. Otherwise its showing "Error Loading control"
I have attached how the logs appear in PowerApps Component Framework test environment.. Please find the same. Please suggest some way to overcome this as this is blocking all work we are doing. Also please give us some details if you could join for a quick call to give some approaches/solutions/work-arounds for this problem. Thanks, Surya
Hi @cchannon
From my observation with regards to your previous comments, The initialization (in init() method) is not happening in the first attempt (i.e ReportId, EmbedToken, EmbedUr = Blank()), also UpdateView() isn't triggered in the first attempt.
But during the second Attempt, Initialization (through init() method) is happening successfully, UpdateView() is executing 4 times. And everything is working as expected.
I am using PCF component to embed Power BI Report. So I obtain the report metadata (i.e ReportId, EmbedToken, EmbedUrl, WorkspaceID) and pass this data to my PCF component. PCF component uses the following Power BI functions:
1. pbi.service.Service(pbi.factories.hpmFactory, pbi.factories.wpmpFactory, pbi.factories.routerFactory)
Same Developer Tools window you used for your screenshots below. Go to Sources, find the index.ts file from your PCF, add a breakpoint.
For more info on adding breakpoints and stepping through, I suggest you just internet search "basics of script debugging in {your browser name}"
Can you suggest how to add debugger to check on this.. Or suggest a tool to debug which would serve our usecase..
Thanks, surya
If updateView never gets called in the first run, do you maybe have some kind of error being thrown during init? Have you tried adding a debugger and walking through to see where the error happens?
WarrenBelz
87
Most Valuable Professional
mmbr1606
71
Super User 2025 Season 1
Michael E. Gernaey
67
Super User 2025 Season 1