web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Start a timer in canva...
Power Apps
Answered

Start a timer in canvas app on button click

(0) ShareShare
ReportReport
Posted on by 42

Hi there. 

 

I am new to canvas apps, and have this currently in my OnSelect property for a button.

 

I need to add to it to start a timer control on the same button click. So I have put the Start property of the timer to a variable called timerStart, and then I tried to add (in the true bit of the If statement), the code of Set(timerStart, true) but a whole host of errors came up. How can I set this variable to true, or otherwise start the timer control on the OnSelect, but only if the If statement = true?

 

Thanks

LM

 

 If(
 IsBlank(
 LookUp(
 Drivers, 
 'Driver Email' = User().Email && 
 'Check In Date/Time' >= DateAdd(Today(), -1) &&
 'Check In Date/Time' < DateValue(Today(), "dd/mm/yyyy")
 )
 ),
 Patch(
 Drivers, 
 Defaults(Drivers), 
 {Name: User().FullName}, 
 {'Driver Email': User().Email}, 
 {'Check In Date/Time': Now()}
 ), 
 Notify("You have already checked-in Today. Select "&Char(34)&"Trips"&Char(34)&"from the bottom menu to resume.",NotificationType.Information)
)

 

 

Categories:
I have the same question (0)
  • Verified answer
    BCLS776 Profile Picture
    8,994 Moderator on at

    You can put multiple statements within an If() statement if you separate each with a ;

     

    In addition, let's fix up your Patch() a bit:

    If(
     IsBlank(
     LookUp(
     Drivers, 
     'Driver Email' = User().Email && 
     'Check In Date/Time' >= DateAdd(Today(), -1) &&
     'Check In Date/Time' < DateValue(Today(), "dd/mm/yyyy")
     )
     ),
     Patch(
     Drivers, 
     Defaults(Drivers), 
     {
     Name: User().FullName, 
     'Driver Email': User().Email, 
     'Check In Date/Time': Now()
     }
     );
     Set(timerStart, true);
     , 
     Notify("You have already checked-in Today. Select "&Char(34)&"Trips"&Char(34)&"from the bottom menu to resume.",NotificationType.Information)
    )

    Hope that helps,

    Bryan

  • LostMary Profile Picture
    42 on at

    Thanks for your help. This is great. One other thing, in the same formula...

     

    The column of Check In Date/Time in my Dataverse table of Drivers is of type Date/Time set as Time Zone Independent and appear in Dataverse in dd/MM/yyyy hh:mm:ss.

     

    My formula is meant to Patch them to the table, but only if they don't already exist with today's date (ignoring the time part), but this doesn't seem to work. I, for example, do not have a row with my email address in it, and it is bringing through the false Notify code.  Any ideas what I am doing wrong here?

     

    Here is my code:

     

    If(
     IsBlank(
     LookUp(
     Drivers, 
     'Driver Email' = User().Email && 
     'Check In Date/Time' >= DateAdd(Today(), -1) &&
     'Check In Date/Time' < DateValue(Today(), "dd/mm/yyyy")
     )
     ),
     Patch(
     Drivers, 
     Defaults(Drivers), 
     {
     Name: User().FullName, 
     'Driver Email': User().Email, 
     'Check In Date/Time': Now()
     }
     );
     Set(timerStart, true);
     , 
     Notify("You have already checked-in Today. Select "&Char(34)&"Trips"&Char(34)&"from the bottom menu to resume.",NotificationType.Information)
    )

     

    Thanks in advance,

     

    LM

  • BCLS776 Profile Picture
    8,994 Moderator on at

    I suspect the logic is going sideways with this condition in the LookUp():

    'Check In Date/Time' < DateValue(Today(), "dd/mm/yyyy")

    Today() produces a datetime that corresponds to 12:00am on this day. The only values of a datetime that would be less than this are values from yesterday. Consider replacing Today() with Now() and removing the DateValue() function:

    'Check In Date/Time' < Now()

    This should help capture check ins that have previously happened in the same day

     

    Hope that helps,

    Bryan

  • LostMary Profile Picture
    42 on at

    You are a genius. Thanks so much.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 392 Most Valuable Professional

#2
11manish Profile Picture

11manish 181 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 112 Super User 2026 Season 2

Last 30 days Overall leaderboard