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 / Timer is not running w...
Power Apps
Unanswered

Timer is not running while working together with the patch

(0) ShareShare
ReportReport
Posted on by 34

Hello,

 

I have a button to start the timer while patching some info to the database at the same time. The timer seems not working because the form got refresh after patching. However timer will work if you click on it afterwards. I want to avoid the click, I tried the select function, it doesn't work.

 

Button OnSelect property

 

If(tglTowerOnHoldA.Value=true && ThisItem.'Tower On Hold' = 'Tower On Hold (P2 Batch Sheets)'.No,Patch('P2 Batch Sheets',ThisItem,{'Tower On Hold':'Tower On Hold (P2 Batch Sheets)'.Yes,'Tower On Hold Date':Now()});Set(gblOnHoldTimeAOld,ThisItem.'Tower On Hold Time');UpdateContext({locTimeGo:true});Select(timOnHold_1),tglTowerOnHoldA.Value=false && ThisItem.'Tower On Hold' = 'Tower On Hold (P2 Batch Sheets)'.Yes,Patch('P2 Batch Sheets',ThisItem,{'Tower On Hold':'Tower On Hold (P2 Batch Sheets)'.No,'Tower On Hold Time':gblOnHoldTimeANew,'Tower On Hold Date':Blank()}),tglTowerOnHoldA.Value=true && ThisItem.'Tower On Hold' = 'Tower On Hold (P2 Batch Sheets)'.Yes,Set(gblOnHoldTimeAOld,ThisItem.'Tower On Hold Time'))

 

 

Timer set autostart as true, start as locTimeGo, repeat as true.

 

OnTimeEnd

 

Set(gblOnHoldTimeANew,DateDiff(ThisItem.'Tower On Hold Date',Now(),Seconds)+gblOnHoldTimeAOld)

 

 

Text

 

If(tglTowerOnHoldA.Value=true,Text(Time(0, 0,gblOnHoldTimeANew), "hh:mm:ss"),Text(Time(0, 0,ThisItem.'Tower On Hold Time'), "hh:mm:ss"))

 

Categories:
I have the same question (0)
  • Al_10 Profile Picture
    1,691 Super User 2024 Season 1 on at

    @BigGGG777 

     

    what is the purpose of the timer?

    does it patch to the same datasource (P2 Batch Sheets)?
    what property holds the code to be executed in the timer (OnSelect, OnTimerStart)?

    you form.item = ?

     

    Note:
    you set the timer to autostart and auto repeat, so the timer loops forever until you navigate to a different screen.

    at the same time you trigger the already running timer with a variable.

     

  • BigGGG777 Profile Picture
    34 on at

    Hi,

     

    it's a timer that shows how much time the tower is staying on hold. Basically I grabbed on hold time from the record and use Now() minus it to get the times demonstrating dynamically. 

  • Al_10 Profile Picture
    1,691 Super User 2024 Season 1 on at

    @BigGGG777 

     

    If(
     tglTowerOnHoldA.Value=true && ThisItem.'Tower On Hold' = 'Tower On Hold (P2 Batch Sheets)'.No,
     Set(gblOnHoldTimeAOld, Now());
     Patch('P2 Batch Sheets',ThisItem,{
     'Tower On Hold':'Tower On Hold (P2 Batch Sheets)'.Yes,
     'Tower On Hold Date': gblOnHoldTimeAOld
     });
     Reset(TIMERNAME);
     UpdateContext({locTimeGo: fasle}); UpdateContext({locTimeGo: true});
     Select(timOnHold_1),
     
     tglTowerOnHoldA.Value=false && ThisItem.'Tower On Hold' = 'Tower On Hold (P2 Batch Sheets)'.Yes,
     Patch('P2 Batch Sheets',ThisItem,{
     'Tower On Hold':'Tower On Hold (P2 Batch Sheets)'.No,
     'Tower On Hold Time':gblOnHoldTimeANew,
     'Tower On Hold Date':Blank()
     }),
     
     tglTowerOnHoldA.Value=true && ThisItem.'Tower On Hold' = 'Tower On Hold (P2 Batch Sheets)'.Yes,
     Set(gblOnHoldTimeAOld, ThisItem.'Tower On Hold Time')
    )

     

    if that does not work, how is your form get refreshed after patch?

     

  • BigGGG777 Profile Picture
    34 on at

    I'm not saying patch doesn't work, it worked. The timer is the one who has problem. Basically it wont start unless you give it a click, even though I have a autostart and start as true. Select function is select(timer) which I didn't include in the code because it's not working.

  • dave-jorgensen Profile Picture
    502 on at

    As Alex mentioned - you also need the auto repeat set to true. You have that set correctly?

  • Al_10 Profile Picture
    1,691 Super User 2024 Season 1 on at

    @BigGGG777 

     

    have you tried the code from my last post?


    another question: you have a gallery; that gallery's data source is Dataverse (or any other online db and not a collection); you have a form and its Item property is gallery.selected; correct?

  • BigGGG777 Profile Picture
    34 on at

    Hi Alex,

     

    I have tried that one. not working. I have form item set up correctly.

  • BigGGG777 Profile Picture
    34 on at

    Hi Dave,

     

    Yes I have that set up correctly.

  • Al_10 Profile Picture
    1,691 Super User 2024 Season 1 on at

    @BigGGG777 

     

    with answers you provided, it is difficult for me to follow you....

    you have a button that patches to the datasource. this button is inside a form or a gallery?

    you have a timer. that timer has the same parent as the button?

  • dave-jorgensen Profile Picture
    502 on at

    Hi bigggg. If you have the timer set so auto start=true, start=true, and repeat=true then the timer always runs.

    If your timer isn't running unless you click on it, pretty sure you are missing one of those 3.

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 356 Most Valuable Professional

#2
11manish Profile Picture

11manish 225 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 211

Last 30 days Overall leaderboard