Skip to main content
Post

#PowerPlatformTip 78: 'Efficient Control Reset'

#PowerPlatformTip 78: 'Efficient Control Reset'

TL;DR: Use Reset(Control) for an individual input on the same screen. To reset several supported inputs together, bind their Reset properties to one variable and toggle it.

💡 Challenge

In Power Apps, resetting multiple controls to their default state is tedious if you reset each control individually with the Reset function. It makes the app less efficient and clutters your code with repetitive statements.

✅ Solution

Reset several supported input controls together using a context variable. Link each control’s Reset property to that variable, then toggle it to reset the linked inputs.

🔧 How It’s Done

Here’s how to do it:

1. Create a context variable

🔸 Initialize a screen context variable, e.g. locReset, to false in the screen’s OnVisible property.

2. Link your controls

🔸 Set the Reset property of each supported input control you want to reset to locReset. Reset(Control) cannot reset a control inside a Gallery or Edit form from outside that container.

3. Trigger the reset

🔸 Toggle the variable from the button’s OnSelect: UpdateContext({locReset: !locReset}). Test two clicks in a row with an entry typed in between. Microsoft’s own example of this pattern sets a global variable to true and then straight back to false in the same formula, Set( MyVar, true ); Set( MyVar, false ); with the context variable of this tip that is UpdateContext({locReset: true}); UpdateContext({locReset: false}), see Reset function. Use that form if the second click doesn’t reset.

🎉 Result

You can reset the linked inputs with one button action. Use Reset(Control) when only one control needs resetting.

⚠️ Important Note: Test the reset thoroughly to confirm all controls return to their expected default values.

🌟 Key Advantages

🔸 Efficiency: Reset all controls with one action instead of coding individual reset functions.

🔸 Cleaner Code: Avoid repetitive reset statements for a more maintainable app.

🔸 User Experience: Deliver a quick, seamless reset for better usability.

🎥 Video Tutorial

🛠️ FAQ

1. How do I initialize the reset variable (locReset)?

Set a screen context variable in OnVisible, for example UpdateContext({locReset: false}).

2. Can I reset only a subset of controls?

Yes. Link only the controls you want to reset by setting their Reset property to locReset.

3. What if a control doesn’t reset as expected?

Ensure the control’s Reset property is bound to locReset. Toggle it from the button; for an individual control on the same screen, use Reset(Control).

🔸 How to Implement OnKeyDown/OnKeyPress Behavior in PowerApps Text Input - another pattern built on hidden controls and toggled context variables.

🔸 #PowerPlatformTip 69: ‘Optimize Loading with Fullscreen Reference’ - another one-line change with an outsized impact on app efficiency.

This tip is by Marcel Lehmann, Microsoft MVP (Business Applications) and founder of the Power Platform Academy, which runs free live workshops (in German). See the next free workshop dates (in German). For companies that want this implemented for them, see KMUpower: Power Platform consulting & automation for SMEs (DACH).

This post is licensed under CC BY 4.0 by the author.

Microsoft and the Power Platform product names (for example Power Apps, Power Automate, Copilot Studio) are trademarks of the Microsoft group of companies. This is an independent website. It is not operated, sponsored or endorsed by Microsoft.