DEV Community

Cover image for What Not to Do in Power Apps

What Not to Do in Power Apps

david wyatt on September 30, 2024

There are lots of cool blogs telling you tips on how to build good Power Apps, so I thought I would take a different approach and talk about what y...
Collapse
 
naufalwp profile image
Naufal Wahika Putra

Thank you for sharing the Select() function! I am always been trying to find a way to have reusable code in my Power Apps without the use of components. Duplicating my code leaves me searching the whole apps if there is any code updates

Collapse
 
giboin_florent_2fd457a8ff profile image
Giboin Florent

It's already old fashion ^^. Consider User Define Function. Why ? Because the Select(button) will not work as expected in a ForAll(), it will do everything in the ForAll() then click n times the button.

Collapse
 
wyattdave profile image
david wyatt

True, but User Defined Functions are scoped, so they cant call api's or set variables (Though I do like UDF - dev.to/wyattdave/power-apps-vba-su...) . Yep I experienced that little querk with ForAll(), but in my opnion it isnt a real loop as it can only interact with the collection its looping over (in most cases the code in the select() wouldnt work in the ForAll, apart form Patching I think). So I would use a Timer as a loop if I wanted to loop and press select.

Thread Thread
 
naufalwp profile image
Naufal Wahika Putra

Wow thanks for the info on the User Define Function! Will definitely try to implement that on my next Power Apps. But true its unfortunate that it can't store any variables and collection since I usually collect the data into a collection to avoid any delegation issues.

Collapse
 
andy_l_65049c8cb401baee51 profile image
Andy L

I would much rather use User defined functions for reusable code.

Collapse
 
get-splash profile image
Ash

Love these! Keen to understand how you manage duplicate code when you are working across different screens? From my understanding and experience using a hidden button only works if its on the same screen - how would you call code on a different screen if you wanted to keep the code in one place?

Collapse
 
wyattdave profile image
david wyatt

That is the limit of select. So you are back to duplicating code, but atleaat it's one per screen and easy to find/not miss anything

Collapse
 
balagmadhu profile image
Bala Madhusoodhanan

Lovely best practices !!... love the Pop-Up tips

Collapse
 
andy_l_65049c8cb401baee51 profile image
Andy L

That was truly a good one, will try to implement it as well