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

Does it make sense to use hidden buttons as a substitute for functions?

In essence I have something I do "often", such as for example patching certain information in a very repeatable way. In a more common programming language I would abstract the repeatable part and build a function. In PowerApps (as far as I know?) there is no possibility to build a function. So I was kind of wondering if it would make sense to put the repeatable part of my formula into the OnSelect property of a button which I hide. Then I could always "Select" the button when I need to invoke it, while I would rely on variables to add parameters. 

 

Now I understand that that's a very hacky approach to things and so I am wondering if this makes sense and if there is an alternative available (which does not, for example, involve using PowerAutomate or similar since I don't want to cause extra consumption)

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@-Rem- 

Not really!!

PowerApps is not a development language, so the more you try to make it one, the more you struggle with it!  

 

If you find yourself using a lot of variables, collections, and OnXxxx actions in your app, then you are taking the approach wrong!  That is very programmatic and contrary to PowerApps.

 

Now, there are times that you need very specific behavioral actions in your app - and you don't want to duplicate them.

 

In those cases, the approach of a hidden button or a toggle is not a bad choice.  

Note, the difference between the button and toggle is - the button will provide a synchronous behavioral action and the toggle will provide an asynchronous action (not to introduce too many dev terms here!)

 

Beyond that...if you need a function, then NO, none of the above would apply to that.  A function should be done either in the place you want it (if only once), in a component for reusability, or in a dynamic variable/named function in order to dynamically reproduce the results.

 

So...it is not a concrete answer because there are some factors to consider that you did not specifically spell out in your post, but hopefully this sheds some light for you.

 

_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

View solution in original post

3 REPLIES 3
RandyHayes
Super User
Super User

@-Rem- 

Not really!!

PowerApps is not a development language, so the more you try to make it one, the more you struggle with it!  

 

If you find yourself using a lot of variables, collections, and OnXxxx actions in your app, then you are taking the approach wrong!  That is very programmatic and contrary to PowerApps.

 

Now, there are times that you need very specific behavioral actions in your app - and you don't want to duplicate them.

 

In those cases, the approach of a hidden button or a toggle is not a bad choice.  

Note, the difference between the button and toggle is - the button will provide a synchronous behavioral action and the toggle will provide an asynchronous action (not to introduce too many dev terms here!)

 

Beyond that...if you need a function, then NO, none of the above would apply to that.  A function should be done either in the place you want it (if only once), in a component for reusability, or in a dynamic variable/named function in order to dynamically reproduce the results.

 

So...it is not a concrete answer because there are some factors to consider that you did not specifically spell out in your post, but hopefully this sheds some light for you.

 

_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

Hey Randy,

 

thanks for the info, that actually made a lot of sense to me.

 

After reading your post... I decided I don't want to go down the hidden button route. I think it would have solved my issue, but I have the feeling that once I start running with hidden buttons I'll end up using 200 of them on each screen...

 

My alternative now is that I am filling up a collection that contains the absolute minimum info I need, put it all in a ForAll and so only do "one" patch (or rather only type down the code for the patch once). I am not sure why I didn't do it that way in the first place but, eh, hindsight...

 

Either way, thanks Randy!

RandyHayes
Super User
Super User

@-Rem- 
See there...too much "programming" in your mind on this!  😉

 

There is no such things as a For Loop in PowerApps (again, not a development langauge).  ForAll is not a For Loop - it is a function that creates a table!!  Everyone completely misuses it as a For Loop because they can "kind of" make it do that action.  But, your performance will degrade very quickly if you use it as a for loop!!

 

PowerApps really is a completely different way of thinking than in a development environment!!

 

If you have a need for 200 functions, then you're probably again, looking at this the wrong way. 

 

Keep this in mind - PowerApps was modeled completely after Excel.  It is Excel on steroids!!  In Excel, you reference everything and use formulas to provide results you want...same thing in PowerApps!

The more you stick to that and use behavioral actions as an exception and not as a rule, then the better the experience, the better the app, the faster to design, and the easier to maintain it will all be!

 

_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,848)