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 / Reusable formulas usin...
Power Apps
Unanswered

Reusable formulas using OnSelect and a button, am i doing things correctly

(0) ShareShare
ReportReport
Posted on by 1,809 Super User 2024 Season 1

I have this formula, that are been called inside 2 locations:-

 

 

//store the options to popualte the dropdowns based on the available data onky
ClearCollect(colOptionsForChoices,Filter('Work Orders',
('Work Order Status'.Value = "Assigned" Or 'Work Order Status'.Value="New") And
(Street = colSelectedStreetName Or IsBlank(colSelectedStreetName)) And
(Direction = colSelectedDirectionName Or IsBlank(colSelectedDirectionName)) And
('Location Name' = colSelectedLocationName Or IsBlank(colSelectedLocationName)) And
('Work Order Type'.Value = colSelectedTypeName Or IsBlank(colSelectedTypeName)) And
('Technician Name'.Email = colSelectedTechnicianName Or IsBlank(colSelectedTechnicianName) Or 'Work Order Type'.Value ="Posting"
Or 'Work Order Type'.Value ="UnPosting" Or 'Work Order Type'.Value ="Campaigns Photos" ) And
(Brand = colSelectedBrandName Or IsBlank(colSelectedBrandName)) And
('Work Order Status'.Value = colSelectedTStatusName Or IsBlank(colSelectedTStatusName))
));

 

 

1) Screen OnVisible

2) Clear button

 

currently i am adding the same formula twice, and when i want to modify it i need to do this twice. so i find a solution , where i can add a hidden button with this formula inside the button OnSelect() propert, and then I can call this button using Select(buttonname).. it worked for me, but not sure if this method is fine or it has drawbacks i am unaware of?

 

Thanks

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    @johnjohnPter ,

    I use Select(ControlName) on hidden buttons/icons regularly and have had no issue with their operation.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • johnjohnPter Profile Picture
    1,809 Super User 2024 Season 1 on at

    @WarrenBelz so you also use this appraoch for code reuse? or for other purposes?

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    @johnjohnPter ,

    Two purposes mainly - multiple instances of the same code (the same as yours) and also when I have a large number of  variations of code running off a Switch statement (primarily gallery based menu buttons) where the code just gets too big and needs a bit of breaking up.

  • NiranjanD Profile Picture
    5 on at

    I guess using a Select(HiddenButton) might complicate the app design in future, because there will be a lot of buttons and any developer who comes after this might get puzzled on the same. so I guess, I would group all such buttons meant for code reuse under a group, and hide them, so it would be handy for people to differentiate between functional buttons and buttons that trigger a routine.

    and also, if a button is placed in a different screen and called upon, the other screen will be rendered according to PowerApps design, so I think putting a dedicated screen with no functionality would also isolate these coding blocks and makes them reusable throughout the app

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    @NiranjanD ,

    The only issue is that you can only use Select(Control) for objects on the same screen. I certainly group mine, make them small and hide them in a corner (generally bottom right). I have a name for the Group such as grpHiddenSelections

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