cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gclifford
Helper I
Helper I

Best way to handle reuseable code?

Hello,

 

I have a bunch of code being used repetitively in my app - an example is that I need to update a collection, clearcollection(x,y,x,y), and the formula is very long and complicated.  Currently I have this same clearcollection command copy/pasted onto many pages within the application so that it gets updated as needed.  Is there a way to wrap this into a function of some kind and then just call the function on each page so that if I ever need to update the formula for the collection I can do in a single place?

 

I have many other use cases like the above - this is just an example.

 

G

17 REPLIES 17

Hi @KrishnaV  and @mdevaney ,

Not wanting to hijack this thread, but this is something we all could use. I have been trying all sorts of things myself in the past and the hidden button on the same screen is the best I could do. As below, The toggle resets, but does not trigger the OnSelect event.

SelectToggle.gif

There is obviously something I am missing here.

 

@WarrenBelz @eka24 @gclifford 
I should have said OnCheck property, not OnSelect.  My apologies.

OnCheck will work here.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Hi @mdevaney ,

 

Sorry I got late with other work, Thank you for updating with the correct property but I am able to get with OnChange seamlessly. I am doing 3 things:
1. Setting a global variable

2. Resetting the collection

3. Sending email

 

Reset Toggle.gif


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

@KrishnaV 
I am glad to see you got it working my friend!

Hi @gclifford ,

 

I hope you got the idea of how to implement the code reusability in PowerApps. 


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

@KrishnaV & @mdevaney ,

Yep - OnChange works perfectly on both true and false with the toggle variable.

Strange how solutions seem so obvious when you see them and so daunting when you do not . . .

Wow - thank you all for such a great response on this.  Before I start to test I want to make sure I understand fully as I am new to PowerApps.

 

Can I create a create a "variables" screen that holes all of these phantom toggles? The code I want to re-use is used in many screens - can I call the toggle on my variable screen from other screens?

@gclifford 

I know you can use a separate screen for phantom toggles on Chrome, Firefox and Edge.  Not sure about IE, you’d have to test that browser.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,495)