Skip to main content

How to Add a Refresh Button to a Screen in Power Apps

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

A Refresh button lets people reload a screen's data without leaving it. The neat way to build one: move the screen's loading formula into the button's OnSelect, start it with Refresh, and make the screen's OnVisible select the button. Opening the screen and selecting Refresh then run the same formula.

Prerequisites​

Step 1: Add the Button to the Header​

Select the header container and insert Input → Button (How to Add a Button in Power Apps). It goes in at the end of the container. In the example, the title fills the space in between, so the button sits at the right edge. Rename it, for example btnRefreshMPS on the My Plan screen, and set:

PropertyValue
Text"Refresh"
Icon"ArrowClockwise"
Width, Height112, 40
AccessibleLabel"Refresh this screen"

The example keeps the default Appearance, Primary, like the Back button on the same colored header (How to Add an Icon to a Button).

Step 2: Move the Loading Formula into the Button​

Cut the screen's OnVisible formula and paste it into the button's OnSelect. Then add Refresh for each data source the screen reads, right after the line that shows the spinner (How to Refresh Data with the Refresh Function):

A code window titled btnRefreshMPS → OnSelect: UpdateContext sets locIsLoading to true, Refresh runs on RoleCompetencies and CompetencyResponses, Concurrent loads the active competencies for MyJobTitle into locMyPlan and the person's responses into locMyResponses, and locIsLoading is set back to false

btnRefreshMPS → OnSelect
UpdateContext({locIsLoading: true});
Refresh(RoleCompetencies);
Refresh(CompetencyResponses);
Concurrent(
UpdateContext(
{
locMyPlan: Sort(
Filter(
RoleCompetencies,
JobTitle = MyJobTitle && IsActive
),
Competency
)
}
),
UpdateContext(
{
locMyResponses: Filter(
CompetencyResponses,
EmployeeId = MyProfile.id
)
}
)
);
UpdateContext({locIsLoading: false})

The spinner shows while the lists refresh, because locIsLoading is set first.

Step 3: Make OnVisible Select the Button​

My Plan Screen → OnVisible
Select(btnRefreshMPS)

Select runs a control's OnSelect as if someone had selected it (How to Use the Select Function). Microsoft's reference sets four rules, and this fits all of them (Select function):

  • Select only works on the same screen, and the button is on it.
  • It only works in behavior formulas, and OnVisible is one.
  • A control can't select itself.
  • It queues the OnSelect, so it may run just after OnVisible finishes.

The example leaves the button's DisplayMode alone. Microsoft's reference doesn't say whether Select works on a disabled control, so the button stays enabled.

Step 4: Copy It to Other Screens​

Build the button once, then copy it (How to Copy and Paste Controls Between Screens). For each screen:

  1. Select ... on the finished button → Copy.
  2. Select ... on the other screen's header container → Paste. The copy lands at the end of the header with _1 added to its name.
  3. Rename it for its screen, such as btnRefreshMTS.
  4. Replace its OnSelect with that screen's OnVisible formula plus Refresh, and set the screen's OnVisible to Select() on the new button.

Copy the button again before each paste. Pasting a formula into OnSelect puts the formula on the clipboard, and the next paste fails (Fixed: "There's Something Wrong with the Pasted Code").

Step 5: Test It​

Preview the app, open the screen, and change something from somewhere else, such as another person's session or the SharePoint list. Then select Refresh. In the example, a manager's My team screen was open when an employee sent a response. Before Refresh:

The My team screen with Back, the title My team and a Refresh button in the header, and Olivia Bennett with no badge

After Refresh, her row has its Waiting for review badge:

The same screen after Refresh, with a yellow Waiting for review badge on Olivia Bennett's row

On a phone, the header has less room for its buttons. How to Show Only the Icon on a Button on Phones shows the button as just its icon there.

Common Mistakes​

MistakeWhat happensDo this instead
Refresh(...) alone in the buttonScreens that use variables keep their old copyPut the whole loading formula after Refresh
Keeping the formula in OnVisible and copying it into the buttonTwo copies to keep in stepOne formula in the button, Select() in OnVisible
Selecting a button on another screenSelect doesn't work across screensGive each screen its own button

Troubleshooting​

SymptomLikely causeFix
The screen no longer loads when openedOnVisible doesn't select the buttonSet OnVisible to Select() on the button
Errors on many controls after removing a buttonThat button's formula was what created their variablesPut the formula back, or paste a copy and set its OnSelect
The paste failsThe clipboard holds a formulaCopy the button again

FAQ​

Why not just call Refresh in OnVisible?​

That covers opening the screen. The button covers people who stay on it, such as a manager waiting for responses. With Select, both share one formula.

Does the button need a confirmation?​

No. It only reloads data. Anything not yet saved on the screen, such as text typed in a box, is reset only if the screen's loading formula resets it.

Conclusion​

Put the screen's loading formula in a Refresh button, starting with Refresh(), and make OnVisible select it. Opening the screen and pressing Refresh then run one formula, and the button copies to other screens with only its formula changed.

Additional Resources​

Stay Updated

Subscribe to our newsletter for the latest tutorials, tech insights, and developer news.

By subscribing, you agree to our privacy policy. Unsubscribe at any time.