Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Answered

PCF control initializes before full form load and doesn't trigger updateView

(1) ShareShare
ReportReport
Posted on by

Hi all

 

We've already a ticket open at microsoft and I'm now curious if any of you ever faced this issue.

 

We developed a pcf control with react which formats and validates phone numbers bound to standard phone fields. Only on the production environment (fastest environment, approx. 2k users daily) we have the issue that in some cases the pcf control doesn't receive any props (phone number and iso code for formatting) when the form has fully loaded. UpdateView just doesn't get called anymore and due to a mistake in react pattern phone numbers got overwritten with null. We fixed this:

 

private _numberChanged(newNumber: string) {
 if (newNumber !== this._properties.initialNumber) {
 this._value = newNumber;
 this._notifyOutputChanged();
 }
 }

 

but now the users cannot tell if this record has a phone number or not, possibly generating overhead when they realize the phone number is missing and have to look it up. The pcf control follows best practice, there are no known anti-patterns used. 

 

So to us this seems to be a platform/framework issue due to some strange race conditions as it only happens on the fastes environment. We could never reproduce the issue on any other environment or customer.

 

Any ideas? Any hints?

 

Thanks in advance!

  • Community Power Platform Member Profile Picture
    on at
    Re: PCF control initializes before full form load and doesn't trigger updateView

    Interesting solution. But still very annoying, to make PCF work we have to come back to modify form JS, hopefully MS would improve it in future.

  • Beyro Profile Picture
    32 on at
    Re: PCF control initializes before full form load and doesn't trigger updateView

    Sure. Let's say your control is bound to field with name `pub_somelookup`. 

    Configure that field to be hidden by default on your form.

    Add JavaScript to the form to show that field in the onload event.

    `formContext.getAttribute('pub_somelookup').setVisible(true)`.

    Your PCF init and `updateView` code will not fire until the form onload event shows the field, and because onload event has fired, the field will guaranteed have the actual value.

    If you need a more detailed example, let me know.

  • JVega Profile Picture
    3 on at
    Re: PCF control initializes before full form load and doesn't trigger updateView

    Hello Beyro, do you mind showing an example that worked for you?

  • Kaushik Kaul Profile Picture
    Microsoft Employee on at
    Re: PCF control initializes before full form load and doesn't trigger updateView

    This seems like a bug. Was this working for you before and has recently broken? Can you add your control for me to take a look.

  • Verified answer
    Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at
    Re: PCF control initializes before full form load and doesn't trigger updateView

    Hi @Doetz , 

    it is the expected behaviour that the values are not there during the init.
    Sometimes they are not there not even for the first call in updateView, but at least the last call in updateView will have the right value.

    Also, inside a PCF it's not supported to work with the Xrm.* object. That's stated in the sdk: https://docs.microsoft.com/en-us/power-apps/developer/component-framework/reference/?WT.mc_id=BA-MVP-5004107

    The best practice is to use the form scripting OnLoad and OnChange events, and check there the value, and set there the field notification: https://docs.microsoft.com/en-us/power-apps/developer/component-framework/code-components-best-practices?WT.mc_id=BA-MVP-5004107#do-not-interact-directly-with-formcontext

     

  • Doetz Profile Picture
    2 on at
    Re: PCF control initializes before full form load and doesn't trigger updateView

    Hello,

    we are also facing the same issue but it is not on Lookup-fields. We have the problem on SingleLine.Text fields. In DEV environment everything was working fine but in the other environments this problem occured. The PCF component is having null values on init. We are using React and Fluent UI to render the PCF. Additionally we check the field attributes if the field is required and based on that set error messages for required fields using Formcontext (window.getcurrentxrm) and not only "pcf-context".

     

    We tried many things to resolve the problem:

    - Tried to put a delay in init using settimeout method, but this broke the pcf component because it was not loading properly

    - Tried to retrieve data with an api call but this seems not to be a good approach

    - I'm executing the same methods and steps in init() and in updateview() but this does also not work for us.

     

    @Beyro 's suggestion to use JavaScript and show the field afterwards might be a usefull approach, didnt try it till yet.

     

    Has anyone else any suggestions which could help?

  • Beyro Profile Picture
    32 on at
    Re: PCF control initializes before full form load and doesn't trigger updateView

    The approach I am using right now is to hide the lookup field on the form by default, and then use JavaScript to show the field in the form's onLoad event. If you do that, then the field will have the correct value every time.

  • Community Power Platform Member Profile Picture
    on at
    Re: PCF control initializes before full form load and doesn't trigger updateView

    Yeah lookup fields does have that issue, both 'isPropertyLoaded' or 'loading' are not reliable.

    The best way to handle it is to left them to react to decide, in a short time react will receive two times of value, finally it will show with the value.

    But in some cases, the null value means something and we cannot afford to render with null first.

    Finally we abandoned lookup field in PCF for this case, use a XHR request to fetch it's value instead.

  • Community Power Platform Member Profile Picture
    on at
    Re: PCF control initializes before full form load and doesn't trigger updateView

    I am still seeing this exact same issue - lookup fields are sometimes having a null value during first one to two updateView calls and then finally get the value on the final updateView.

    There is an undocumented property on the lookup called `isPropertyLoaded` that was working for a while as an indicator that the field had loaded but it is no longer working reliably since the last platform update.
    Are there any plans to provide a supported method/property for determining when we can confidently retrieve the value of the lookup field and know that null is because it has no value and not because it has not loaded?

  • Community Power Platform Member Profile Picture
    on at
    Re: PCF control initializes before full form load and doesn't trigger updateView

    We do not encounter this issue anymore. It occured only on one environment which is also the production and most fastest. Microsoft never acknowledged this bug and the issue "resolved itself" for us. You can contact microsoft support though but be aware, you need to reproduce the issue everytime otherwise Microsoft will let you wait.

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 89 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 72 Super User 2025 Season 1

#3
mmbr1606 Profile Picture

mmbr1606 71 Super User 2025 Season 1

Overall leaderboard