cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Tuukka
Frequent Visitor

How to use Timer control between patches

I am quite new with powerapps and I am just finishing my first “complex” powerapp solutions. I don’t just get it how to add timer control between 2 patches. I have a button on my App which includes 2 patch to inserts new row on gallery and after that update sum gallery labels to sql on premise. The code looks like this: SubmitForm(Form1_5);;Set(VarStartTimer; true);;Patch('[dbo].[xxx]'; LookUp('[dbo].[xxx]'; ID = Gallery1.Selected.ID); {KPL:Value(Label173_1.Text);EHtm2:Value(Label176_1.Text);Yht:Value(Label175_1.Text)}) P.S. we use ; instead of , like you do in US.

 

On Timer function I use Durations of 5000, OnTimerStart: false, OnTimerEnd: Refresh('[dbo].[xxx]'), Start: VarStartTimer, Repeat:false, Reset:false, Autostart:false, AutoPause:false

 

It works if I add just 1 new record but do not update the second one with Sum labels even I wait more than 5 seconds before next trigger.

2 ACCEPTED SOLUTIONS

Accepted Solutions
poweractivate
Community Champion
Community Champion

@Tuukka 

 

Instead you should do it in one or more Timers only with the variables setting it and put the patches in the OnTimerStart or OnTimerEnd.

 

It also can work the way you are doing it but you may need to make sure to set the start variable that was set to true and that started the timer back to false at the OnTimerEnd of the Timer itself that is running that is having the issue - this part is tricky and you may need to play with it - that may be why it is only working the first time and not on subsequent times.

 

For more help on this you can check this example Recipe:

 

App Timer Wait Recipe 

 

See if the above recipe helps. Note that above is recipe, not an exact answer to your specific problem. You would still have to adapt it. First check if you can adapt it yourself based on the above recipe - if you try it and after that still have trouble, you can reply here and we might check if we can help you further.

View solution in original post

Tuukka
Frequent Visitor

I finally figured it out. It took some time to play with it. Thanks @poweractivate  I just added UpdateContext({VarStartTimer2: true}) for save button and on the Timer control I put for OnTimeStart my first Patch and on the OnTimerEnd: UpdateContext({VarStartTimer2: false});;Reset(Timer3) and my last patch. For Start On Timer I put VarStartTimer2.  

 

I did also removing and updating buttons on same way. Works like a charm. 🙂

View solution in original post

3 REPLIES 3
poweractivate
Community Champion
Community Champion

@Tuukka 

 

Instead you should do it in one or more Timers only with the variables setting it and put the patches in the OnTimerStart or OnTimerEnd.

 

It also can work the way you are doing it but you may need to make sure to set the start variable that was set to true and that started the timer back to false at the OnTimerEnd of the Timer itself that is running that is having the issue - this part is tricky and you may need to play with it - that may be why it is only working the first time and not on subsequent times.

 

For more help on this you can check this example Recipe:

 

App Timer Wait Recipe 

 

See if the above recipe helps. Note that above is recipe, not an exact answer to your specific problem. You would still have to adapt it. First check if you can adapt it yourself based on the above recipe - if you try it and after that still have trouble, you can reply here and we might check if we can help you further.

View solution in original post

Tuukka
Frequent Visitor

Hi, thanks for the tip. I have now tried on both way with no succeed as you mentioned. I checked out your recipe also but I didn't find how to adapt it in this problem. 

Tuukka
Frequent Visitor

I finally figured it out. It took some time to play with it. Thanks @poweractivate  I just added UpdateContext({VarStartTimer2: true}) for save button and on the Timer control I put for OnTimeStart my first Patch and on the OnTimerEnd: UpdateContext({VarStartTimer2: false});;Reset(Timer3) and my last patch. For Start On Timer I put VarStartTimer2.  

 

I did also removing and updating buttons on same way. Works like a charm. 🙂

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,622)