cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
martinav
Super User
Super User

Commonising reduntant "OnSelect" commands for multiple objects

I have several labels, buttons, etc that need to execute the exact same commands.  I was hoping to find a way to have a common point to direct the OnSelect of all of these items, so when I need to make a change to these common commands, I dont have to copy them to 20 different OnSelect controls.  Any help on this one?

 

Common commands:

 

UpdateContext({WhereUsedSelected:PlainText(ThisItem.Result)});UpdateContext({ CurrentRevision:Value(LookUp(Master_Drawing_List,MD_PartNumber=Text(WhereUsedSelected)).MD_LatestRevNumber), CurrentShown:true});UpdateContext({LookupFilename:LookUp(Drawing_Vault,DV_PartNumber=Text(WhereUsedSelected) And DV_RevisionNumber=CurrentRevision,'{FilenameWithExtension}')});  UpdateContext({NextRev:CurrentRevision+1}); ClearCollect(PdfContent, DataCentralViewPDF.Run(LookupFilename))

 

1 ACCEPTED SOLUTION

Accepted Solutions
tommyly
Responsive Resident
Responsive Resident

I have been creating invisible buttons that I name something like functionDoThis. And then I type in the redundant code into the functionDoThis.OnSelect. Everytime I want to invoke that redundant code, I just type in Select(functionDoThis).

Note that you can only select an object that is on the same screen, so the so-called function would only work within the context of its screen.

This may not be the best way to do this, but it works for me. If you can't find anything better, I hope this works for you 🙂

View solution in original post

3 REPLIES 3
tommyly
Responsive Resident
Responsive Resident

I have been creating invisible buttons that I name something like functionDoThis. And then I type in the redundant code into the functionDoThis.OnSelect. Everytime I want to invoke that redundant code, I just type in Select(functionDoThis).

Note that you can only select an object that is on the same screen, so the so-called function would only work within the context of its screen.

This may not be the best way to do this, but it works for me. If you can't find anything better, I hope this works for you 🙂

No, this sounds perfect.  It will handle exactly what I need.  Thanks so much!

Good thoughts and thank you.

We need this to work on multiple screens.

Reusable functions functions (and patch statements) would be a great addition to the PowerApps product.

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

<
Users online (3,003)