Timer Triggers in Canvas App

Timer triggers in a Canvas app are used to perform specific actions or tasks after a specified amount of time has elapsed. Timer triggers can be useful in many scenarios, such as automating background tasks, displaying a message for a limited time, or updating data periodically.

To use a timer trigger in your Canvas app, you can add a Timer control from the Controls pane and then set its properties in the Properties pane. The Timer control has several properties that you can configure:

  1. Duration: This property specifies the amount of time in milliseconds that the timer should run. You can enter a numeric value or use a formula to calculate the duration dynamically based on other factors, such as user input or data from a data source.  
  2. Repeat: This property specifies whether the timer should repeat its countdown after it reaches its end time. You can set this property to true to make the timer loop indefinitely, or false to run the timer only once.  
  3. AutoStart: This property specifies whether the timer should start automatically when the screen or the control becomes visible. You can set this property to true to make the timer start immediately, or false to start it manually using another trigger, such as a button or a dropdown list.  
  4. OnTimerEnd: This property specifies the action or task that the app should perform when the timer reaches its end time. You can add a formula to this property to customize the behavior of the timer, such as updating a variable or navigating to a different screen.  

When the timer is running, it displays the remaining time in a label control. You can customize the appearance and behavior of this label control using the properties in the Properties pane, such as font size, font color, and alignment.

To access the value of the timer control in a formula, you can use the TimerValue function. This function returns the remaining time of the timer in milliseconds, which you can convert to other units, such as seconds or minutes, using simple arithmetic operations. For example, if you want to update a label control with the remaining time in seconds, you can write a formula like this:

UpdateContext({RemainingTime: Round(TimerValue/1000)})

This formula uses the UpdateContext function to store the remaining time in a variable called RemainingTime, and the Round function to convert the value to a whole number. You can then bind the text property of the label control to this variable using the formula bar or the Properties pane.


Posted

in

by

Tags: