How To Add Delay Or Wait Until In PowerApps

Scenario

 
You might have come across a requirement or situation where you want your PowerApps app to just wait for something; i.e. it should just stay idle for a few seconds.
 
I had a situation where I was running a FLOW from my app to update an Excel file in OneDrive. Once the FLOW run is complete I needed to download the excel file for the  user. If I immediately download the Excel file after FLOW runs, I would get an old excel file with old data. But if I go to OneDrive and check the file, it's already updated with the latest data. So, maybe FLOW OneDrive connector takes time to commit the changes to the file.
 
So as a solution I had to add a delay of 10 seconds before I downloaded the file for user. How should I do this in PowerApps?
 

Solution

 
Timer Control. Using timer control we can add delay in the actions in PowerApps. Let’s see how to use Timer control.
 
Open your app in PowerApps Web Studio >> From Insert tab, Input section >> Select Timer control
 
How To Add Delay Or Wait Until In PowerApps
 
We need to set a few properties of this Timer control like:
 
Duration – the value needs to be provided in milliseconds. This will decide how long the timer will run.
Reset – set the value to true, this will help in running timer multiple times if needed.
OnTimerEnd – We need to write action here, an action which you want to perform after the delay is over after the wait is finished. In my example, I want to show a button to download the file.
Start – Set it to a Boolean variable. Let’s set this Boolean variable from another event.
 
How To Add Delay Or Wait Until In PowerApps
 
Boolean variable set to Start property of Timer.
 
How To Add Delay Or Wait Until In PowerApps
 
On click of Generate Report, I have a FLOW to run. Once that FLOW run is completed – I want to add a delay of 10 seconds. So, I will set Timer Start Boolean variable to true here.
 
How To Add Delay Or Wait Until In PowerApps
 
So, this will start the timer. And after 10 seconds the button to download the file will be shown.
 
Note
You need to set this VarStartTimer variable to false either on screen becoming or OnStart event of the app.
 
Check out Microsoft documents for more information about Timer control.
 
We can use Timer control to animate control appearance, and to show count down effect on your app screen. There are some other properties like AutoPause, Repeat,and AutoStart which we can use depending on the business logic to be implemented.
 
AutoPause - Whether the timer control automatically pauses if the user navigates to a different screen.
AutStart - Whether the timer control automatically starts to play when the user navigates to the screen that contains that control.
Repeat - Whether a timer automatically restarts when it finishes running.
 
Set the visible property of this control to false. To achieve delay or wait we don’t need to show the timer control to the user, it will be hidden and doing its job in background.
 
That's it. I hope this helps. Thanks for reading. 


Similar Articles