How to introduce Delay or Wait in actions in Power apps canvas apps

Hello everyone and welcome to my blog. I today’s blog I will discuss on how you can introduce timeout/ wait/ delay for your actions in Power Apps canvas apps.

Let’s take an example scenario to understand when you may need this feature. I have a very simple form to create a contact and once the contact is created, the user will be taken to the list page. In our case the list page is Screen1.

Below is the code on ‘OnSelect‘ of the button.

No big surprise here. The usual SubmitForm function to save the record and then Navigate function to take the user to Screen1.

Well so far so good. But there is a problem. On create of contact record, I am triggering an automated cloud flow to create a folder in SharePoint. And since it is an automated cloud flow, it may take some time for the folder to create.

My requirement here is to introduce a delay say of 10 seconds, for this example, before the user is taken to Screen1. Basically I want to write something as shown in the below screenshot so that the Navigate function is executed 10 seconds post form submit.

As you can see, there is no Wait function. Nor there is a Delay or Timeout function which can be used. What is my other way to achieve this requirement?

Well, in Power Apps we have to take help of the Timer Control. Insert a Timer control on the form and set the following properties

  1. Duration to 10 seconds. Remember this is the delay you wish to have. If you want to put a delay of 30 seconds, put 30000 in the Duration field. The duration field takes the time in milliseconds.

2. The Start property to a variable startTimer. Don’t worry about the error. It will disappear soon. Just go with the flow.

3. OnTimerEnd property to the following formula.

If you have noticed, I have moved the Navigate function to here and before that set the startTimer property to false. This is to ensure the timer is ready for the next button click operation.

And now finally I modify the ‘OnSelect‘ of the button to the below formula.

As you can see, there is no Navigate function here.

So what exactly happens now? As I click on the button the following sequence of events get executed.

  1. The form is submitted to create the contact record.
  2. startTimer variable is set to true
  3. Since the Start property of the Timer is bound to startTimer variable, the Timer starts.
  4. Timer ends post the specified Duration.
  5. When the Duration is over, OnTimerEnd event fires. This where we set the variable to false again and then Navigate.

Let’s see the whole behavior in action in the below video.

The video illustrates the screen waiting for 10 seconds before navigating to Screen1. Off-course you may not want to show your timer to the end users. In that case, set the Color and Fill property to Transparent for the Timer control.

Hope you liked this post. If this post has helped, you can buy me a coffee. Links on the right side panel.

You will also like the below posts.

Debajit Dutta
Business Solutions MVP


Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe to get the latest posts sent to your email.

Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading