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
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.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

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.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

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