web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / PCF Component not Load...
Power Apps
Unanswered

PCF Component not Loading in First Attempt (updateView() isn't triggering)

(0) ShareShare
ReportReport
Posted on by 21

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:

  1. init()
  2. updateView()
  3. getOutputs()
  4. destroy()

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.

I have the same question (0)
  • cchannon Profile Picture
    4,702 Moderator on at

    Are you sure updateView is not getting called? Or is it maybe getting called, but whatever bound/input parameter you are expecting is null?

     

    A common issue we see on the forum here is that updateView can execute multiple times during a form load event and under other conditions. Whatever updated value is triggering the updateView is not actually guaranteed to be there on every execution though. Instead, say we have a form load event (the most common way we this issue is reported) and in that form load we want to render a PCF using a specific bound attribute. Even if we KNOW that column has data, init() is not guaranteed to have the value in parameters (could be null) and even updateView() is also not guaranteed to have it (could also be null).

     

    BUT... updateView can execute multiple times in a row (often two or three times) and it IS guaranteed to have those values by the LAST time it runs. So, if it runs three times during that form load, the first time it gets called your bound param could be null, the second time it could also be null, but the third and last time, it will have your value. You need to handle null params VERY carefully therefore, so that if a later updateView execution comes in with values it can override whatever null value determinations you might have made in prior execution.

  • surya_kiran Profile Picture
    21 on at

    Hi @cchannon,

    While using web link of PowerApp, in first attempt updateView was not called as per Console logs. I have attached Screenshot of logs generated when I navigate to Report Screen where my PCF component is embedded.

    Also during first navigation.. it shows "error loading control" even though from PowerApps all the parameters are given to PCF component. 

    Subsequent times, updateView is getting called and PCF is successfully loaded. Attached log screenshot.

     

    Please through some light on how I can debug whether my init is working fine and that parameters have value or not when I run my powerapp.

     

    Thanks for the quick reply.!

  • cchannon Profile Picture
    4,702 Moderator on at

    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?

  • surya_kiran Profile Picture
    21 on at

    Can you suggest how to add debugger to check on this.. Or suggest a tool to debug which would serve our usecase..
    Thanks, surya

  • cchannon Profile Picture
    4,702 Moderator on at

    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}"

  • surya_kiran Profile Picture
    21 on at

    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)

    2. powerbi.reset(reportContainer)
    3. powerbi.embed(reportContainer, config)
    to embed the report.
     
    Please suggest what might be going wrong here.. We can also have a short call to clarify this issue if you have a different view on this. Thanks
  • surya_kiran Profile Picture
    21 on at

    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 

  • surya_kiran Profile Picture
    21 on at

    Hi, Can anyone please help me on this issue i am facing. Any reply would be appreciated. Thanks, Surya

  • cchannon Profile Picture
    4,702 Moderator on at

    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? 

  • Community Power Platform Member Profile Picture
    on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard