Showing results for 
Search instead for 
Did you mean: 
Helper III
Helper III

Custom method/function for avoiding repeated code in powerapp



I have created small app based on sharepoint data.


App pull data from sharepoint and displayes summary using graphs and few labels. There are few actions on app screen like week filter and there is additional filter by some roles using drop downs. App also refreshes data using timer control every 5 min if app is kept running.


Code pulls data from 2-3 sharepoint views and manipulate data based on filters before it is displayed or everytime something changes in drop down screen values are refreshed.


Same code is used for Onvisible of screen, onselect in refresh icon, ontimerend in timer control and onchange in 2 drop downs.


Now there is duplication of codes. If i change anything i have to manually replicate code on all 5 locations on screen. Please suggest is there anyway i can simplify by writing 1 custom functions on powerapps which can be called on all 5 location. This can help me reduce errors and consistancy in reporting on screen.


Thanks and waiting for your reply.





Is it possible if I want to use 1 custom function in all 5 locations on your screen instead of the repeated code?


Hi @Dipak ,


Easy way to do is

1. Add label to your powerapp screen and change visibility to false

2. write your script into OnSelect property of Label

3. You can call this script on other control(s) by calling 


Hope this helps.


Priyank Bhat

Helpful resources

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

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