cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
liun
Level: Powered On

updateView is not called on every attribute change?

Hello- 

I observed a somewhat unexpected behavior. Per documentation: https://docs.microsoft.com/en-us/powerapps/developer/component-framework/reference/control/updatevie... : 

"This method will be called when any value in the property bag has changed. This includes field values". However, it seems the runtime is throttling/staging calls, and skip some calls within a timewindow. 

I have a PCF bound to a field. In my form script, I have code

var myAttr = formContext.getAttribute('myfield');
myAttr.setValue("1");
myAttr.fireOnChange();
myAttr.setValue("2");
myAttr.fireOnChange();
myAttr.setValue("3");
myAttr.fireOnChange();

Then in my PCF I logged the attribute value inside updateView function. 

I was expecting that I see all three values per control, because the fireOnChange should invoke all registered controls that bounded to the field and call the updateView. 

 

I am only getting the value 3, but not 1 or 2. 

 

That seems suggest the runtime somehow stage the call within a timewindow, and only invoke the last one and cancel previous ones. It's not uncommon to do this for performance reasons, but it does impact how client should write code if it is by design. 

 

Anyone from PCF team can comment on that?

 

Thanks!

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Power Apps Staff jolake
Power Apps Staff

Re: updateView is not called on every attribute change?

PCF will only call updateView when the backing data layer tells us there is new data for our property bag. Unfortunately, due to batching that occurs for updates of the data layer, if you do several changes like this in rapid succession they will likely end up batched, and thus your control may only get an updateView for some of the calls. This is by design, but you can be confident that whatever value PCF recieves will the most recent value.

View solution in original post

4 REPLIES 4
ScottDurow
Level 8

Re: updateView is not called on every attribute change?

Bump!

Power Apps Staff jolake
Power Apps Staff

Re: updateView is not called on every attribute change?

PCF will only call updateView when the backing data layer tells us there is new data for our property bag. Unfortunately, due to batching that occurs for updates of the data layer, if you do several changes like this in rapid succession they will likely end up batched, and thus your control may only get an updateView for some of the calls. This is by design, but you can be confident that whatever value PCF recieves will the most recent value.

View solution in original post

ScottDurow
Level 8

Re: updateView is not called on every attribute change?

Great - I think this is pretty clear and makes total logical sense to me.

liun
Level: Powered On

Re: updateView is not called on every attribute change?

@jolake Thank you. It will be nice if the documetation can reflect that as well.

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)
Users online (6,020)