cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
martinav
Community Champion
Community Champion

Custom PowerApp Function? This would simplify my app greatly....

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.

 

https://powerusers.microsoft.com/t5/General-Discussion/Custom-PowerApp-Function/m-p/1452#M899

 

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.

1 ACCEPTED SOLUTION

Accepted Solutions
martinav
Community Champion
Community Champion
8 REPLIES 8
martinav
Community Champion
Community Champion
RandyHayes
Super User
Super User

@martinav 

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)

Set the default of the toggle to runMyRoutine

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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
martinav
Community Champion
Community Champion

@RandyHayes ,

 

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?

@martinav 

Yes, thus the part about adding the Set(runMyRoutine, false) at the end of the Formula in your OnCheck action.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
martinav
Community Champion
Community Champion

Oh.. yea... right!

 

I forgot how to read.

PDA
Frequent Visitor

Hey,

 

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,

@PDA 

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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
PDA
Frequent Visitor

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 !

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!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,373)