Skip to main content
Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

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

(0) ShareShare
ReportReport
Posted on by 3,340

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.

Categories:
  • Community Power Platform Member Profile Picture
    on at
    Re: Custom PowerApp Function? This would simplify my app greatly....

    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 !

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on at
    Re: Custom PowerApp Function? This would simplify my app greatly....

    @Anonymous 

    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.

  • Community Power Platform Member Profile Picture
    on at
    Re: Custom PowerApp Function? This would simplify my app greatly....

    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,

  • martinav Profile Picture
    3,340 on at
    Re: Custom PowerApp Function? This would simplify my app greatly....

    Oh.. yea... right!

     

    I forgot how to read.

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on at
    Re: Custom PowerApp Function? This would simplify my app greatly....

    @martinav 

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

  • martinav Profile Picture
    3,340 on at
    Re: Custom PowerApp Function? This would simplify my app greatly....

    @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?

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on at
    Re: Custom PowerApp Function? This would simplify my app greatly....

    @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.

  • Verified answer
    martinav Profile Picture
    3,340 on at
    Re: Custom PowerApp Function? This would simplify my app greatly....

    Just found this...  Thanks @Meneghino 

     

    https://baizini-it.com/blog/index.php/2017/09/22/powerapps-how-to-reuse-your-code-at-in-the-same-screen/

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1