cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
enelson906
Level: Powered On

Timer resetting itself?

Trying to use a timer with standard Start, Pause, Restart capabilities. Reset is not really important right now, this is a one way ticket.

 

This is in a gallery which might be why it's finicky. I have a column on the gallery source for "started" set to false. I have the timer's start property set to ThisItem.started. I have 2 buttons, one to patch in a "true" to and one to patch in a "false" to the gallery source. Mostly seems to be working. If I hit the button to patch in a "true" the timer starts, if I hit the botton to patch in a "false" the timer pauses, BUT when I hit the button to patch in a "true" again the timer restarts from zero. I need it to pick up where it paused.

 

What's strange is that if I simply use the timer itself as a button it does what I want. Click to start, click to pause, click to keep going. Even though the OnSelect property is set to "false". This ultimately won't work because I need the timer hidden. Any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
GarethPrisk
Level: Powered On

Re: Timer resetting itself?

Keep in mind that the Timer's Text property doesn't have to be the Timer's Value.

You were going to have buttons displayed anyways, so maybe just use different Text, and inherently leverage the Timer's functionality by masquerading it as a 'button.'

 

Any other reasons you would hide the Timer?

View solution in original post

7 REPLIES 7
enelson906
Level: Powered On

Re: Timer resetting itself?

If it's any help to anyone else, it seems to work fine with a toggle switch inside the gallery. So I added a toggle and set the timer's start property to Toggle1.Value

GarethPrisk
Level: Powered On

Re: Timer resetting itself?

A potential solution is to use the Timer control as the button itself. Instead of having two buttons, you could have a single 'button' (Timer control) which is contextually updated based on it's 'state.'

  • Initially, the gallery is populated and the started value is false
  • The Timer control is clicked
    • Triggering the timer to begin
    • The OnSelect function could update the started value to be true (or maybe inverted, as below)
      • UpdateIf(colName,ThisItem.id = id,{started: true} OR
      • UpdateIf(colName,ThisItem.id = id,{started: !started}
  • Other functions can run on this initial click
  • When the Timer is clicked again
    • Triggering the timer to pause
    • If necessary, toggle the started value

 

This assumes the Timer control's Start property remains as ThisItem.started. In that case, setting it True initially will start the Timer and allow it to be paused. However, toggling it again may restart the Timer, so consider that.

 

Also, in my testing, looks like the 2nd row toggle to start its Timer results in odd behavior (starts/freezes at other running Timers value). May need to tweak how it's started, or it may be a bug in the Studio.

enelson906
Level: Powered On

Re: Timer resetting itself?

I'd like to be able to hide the timer. It's really only for background data purposes. I suppose I could set it's visible property to something else. Kinda frustrating this doesn't work.

GarethPrisk
Level: Powered On

Re: Timer resetting itself?

Keep in mind that the Timer's Text property doesn't have to be the Timer's Value.

You were going to have buttons displayed anyways, so maybe just use different Text, and inherently leverage the Timer's functionality by masquerading it as a 'button.'

 

Any other reasons you would hide the Timer?

View solution in original post

enelson906
Level: Powered On

Re: Timer resetting itself?

Ooh, I like that idea.

 

I want the button hidden because this is meant to be for work instructions and don't necessarily want operators to feel "on the clock".

GarethPrisk
Level: Powered On

Re: Timer resetting itself?

Makes sense! Happy coding.

enelson906
Level: Powered On

Re: Timer resetting itself?

So another interesting kink. Using the timer as it's own button works fine, changing the text property is fine. I wanted to tie the text property to an If(ThisItem.started, "Pause?", "Start") and use the OnSelect property of the timer to change ThisItem.started to !ThisItem.started. No problems there except now the timer "button" won't activate the timer. If I take away the patch function I'm using in the timer's OnSelect then the timer works fine. I'll have to keep messing with it tomorrow.

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,294)