I say this post from 2016... where you could have a routine in an OnTimerEnd. Then trigger the timer whever you needed to execute a function. This eliminates having to copy the same routine in many controls... and only then needing to update it in one place.
I am wondering if there is a more proper way of doing this now? Especially since my routine contains a Patch() statement that OnTimerEnd does not seem to like very well.
Solved! Go to Solution.
Think Toggle controls!!
Put a Toggle control on your screen (I usually put them on a totally seperate screen where I can keep all of my "common" formulas).
In the OnCheck action of the toggle, put your formula and at the end, put a Set(runMyRoutine, false)
Anytime you want to "call" your formula, just do a Set(runMyRoutine, true) and it will happen.
Quick and easy collecting of formulas in one place with an "on-demand" ability to execute them.
Hope that helps some.
Looks like that will work too. I presume you have to set it back to false immediately, or soon after, so that you can call it again?
Yes, thus the part about adding the Set(runMyRoutine, false) at the end of the Formula in your OnCheck action.
Thanks for the tip, but i'm encountering some problems while trying to implement it on my app.
The Select method is stipulating that it only works when the two controls are on the same screen, so I didn't try.
For the toggle one (@RandyHayes), I did create a toggle, linked to a variable Var1, that runs my function Fun1 OnCheck. When I set the Var1 to "true" it runs Fun1 perfectly.
This works on the PA studio test mode, but doesn't on my phone (Android). It would seems that the toggle "OnCheck" is not evaluated because on a different screen than the one where I'm changing the variable.
Did you have any similar issues ?
Thanks in advance,
Yes...there is a little more to this that I've recently discovered. Personally I consider it a bug that this works fine in design mode but does not work in Play mode, but, that said...
You need to reference the toggle on the screen you are going to call from. This, for me, is as simple as putting a label on the screen that shows that value of the toggle in its text property and then I make that label visible=false.
That will solve the issue.
Doing the trick on mobile apps indeed !
Thanks a lot @RandyHayes for the tip, was getting mad at copy-pasting my formulae all over the place !
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
At the monthly call, connect with other leaders and find out how community makes your experience even better.