web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Custom PowerApp Functi...
Power Apps
Unanswered

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:
I have the same question (0)
  • Verified answer
    martinav Profile Picture
    3,340 on at
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

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

  • martinav Profile Picture
    3,340 on at

    @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,297 Super User 2024 Season 1 on at

    @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

    Oh.. yea... right!

     

    I forgot how to read.

  • Community Power Platform Member Profile Picture
    on at

    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,

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @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

    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 !

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard