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

OnChange running before data fully loads

Hi-

 

I have an application that does a lot of number crunching based on on the location chosen from a drop down list. Whenever a new location is chosen from said drop down list, I get the "dancing ants" at the top of the screen for a few moments while it calculates the value of each field. 

 

That is all well and good, BUT I am also creating a collection with this data so I can render it as a chart. I create that collection on the OnChange event of the location dropdown. 

 

The problem is that the OnChange event of the location drop down executes imedidately, usually BEFORE all my data is calulated, so my collection often gets the PREVIOUS location's data. 

 

Can I code in a delay before the OnChange runs? Or is there some other event I can write my collection on that occurs AFTER all the fields are computed?

 

Thanks for any help!

 

P.S. I have thought of one inelegant solution: Do all of my caluculations in the location field's OnChange event (rather than in the Default value of each feild) and write them to variables. I would then populate my fields and create my collection using those same variables. Just hoping there is a more elegant/simple solution that I haven't thought of. 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: OnChange running before data fully loads

How about just incorporate a timer? Have OnChange start the timer. Have the time run for 3 seconds. When the timer completes make your collection. 

 

Video: PowerApps Timer Control

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

View solution in original post

3 REPLIES 3
Super User
Super User

Re: OnChange running before data fully loads

How about just incorporate a timer? Have OnChange start the timer. Have the time run for 3 seconds. When the timer completes make your collection. 

 

Video: PowerApps Timer Control

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

View solution in original post

n8greene
Level: Powered On

Re: OnChange running before data fully loads

Thanks, Shane. I don't love the solution because it's one-size-fits-all in terms of the duration of the delay. I will need to set the delay to three or four seconds because sometimes it takes that long, though it often loads almost instantly and the four seconds will seem like an eternity to the user. 


At any rate, I learned something new and I appreciate the response. Also I've learned PowerApps by watching your videos, so thanks for that as well. 

 

I may try my approach of setting variables on the OnChange event of the location field and then using those variables for populating (immediately) the fields AND the collection. I was hoping there was a dynamic way to delay until everything is loaded or some such thing. 

 

I'll mark this as solved because you've answered my question. 

 

Thanks again!

B4rikuda
Level: Powered On

Re: OnChange running before data fully loads

@n8greene, were you successful with an approach other than a timer? 

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,778)