Live training: next batches coming soon. Join the waitlist:Waitlists open:Developer Training →Developer →Copilot Studio Training →Copilot Studio →

Power Apps Button OnSelect: Run Multiple Actions in One Click (Build Along)

The service desk team asked for a Save button that does more than save. One click should confirm the title in a green banner, keep a running count of saves, remember the last title, and put the title box back to its default for the next request.

That’s four actions behind one button, and Power Apps handles it with a single formula.

In this tutorial, we’ll build that screen with the power apps button onselect property. You’ll chain multiple actions with semicolons, run one button’s OnSelect from another with Select, and open a second screen with Navigate.

After the build, we’ll cover patterns from real apps: submit and navigate, run a flow, change a button’s color when it’s selected, and why a gallery or container OnSelect sometimes seems to do nothing.

Here’s what we’re building. This is the screen right after one click on Save request:

Power Apps Preview after one click on Save request with the Saved banner, save count 1 and last saved title

Before You Start

You need a Power Apps license (most Microsoft 365 business plans include one for standard connectors) and permission to create apps in your environment. If canvas apps are new to you, our Power Apps tutorials hub covers the basics first.

Two terms come up a lot. A property is a setting on a control, such as Text or Fill. OnSelect is a behavior property: it doesn’t calculate a value, it runs actions when someone clicks or taps the control.

This screen doesn’t read any list data, so all you need are these six controls:

NameTypeNotes
txtOsTitleText inputDefault is “Replace keyboard”
btnOsSaveButtonText “Save request”; the four-action OnSelect
btnOsAgainButtonText “Run Save again”; OnSelect = Select(btnOsSave)
btnOsGoButtonText “Open comments screen”; navigates away
lblOsCountText labelShows the global variable gblSaveCount
lblOsLastText labelShows the context variable locLastTitle

And these are the test inputs we’ll use in Preview:

ActionTitle in the box
Type a title, then select Save requestMonitor flickering
Select Run Save againReplace keyboard (the default, after Reset)
Select Open comments screen(no input)

Step 1: Create a Blank Canvas App

I’m adding a new screen, scrOnSelect, to the same Service Desk Demo app I used for the Power Apps Notify function walkthrough. If you’re starting fresh, create the app first:

1. Go to make.powerapps.com and select Start with design on the Home page:

Power Apps maker portal Home page with Start with design highlighted for a new canvas app

2. Select Create from blank to start an empty canvas app:

Power Apps Create from blank option selected to build the button OnSelect demo app

3. Under Start with a blank canvas, pick Tablet. Power Apps Studio opens with an empty screen:

Start with a blank canvas dialog with the Tablet layout chosen for the OnSelect app

Rename the screen to scrOnSelect in the Tree view (double-click its name). Press Ctrl+S and give the app a name; save again after each step.

Checkpoint: Power Apps Studio shows an empty scrOnSelect screen, and the app is saved.

Step 2: Add the Text Box, Buttons and Labels

Everything we need is on the Insert menu:

Power Apps Insert menu with Text input, Text label and Button controls highlighted
  1. Insert a Text input, rename it txtOsTitle, and set its Default property to "Replace keyboard".
  2. Insert three Button controls. Rename them btnOsSave, btnOsAgain and btnOsGo, and set their Text to "Save request", "Run Save again" and "Open comments screen".
  3. Insert two Text label controls named lblOsCount and lblOsLast, and give them the Text formulas below.
"Saves this session: " & gblSaveCount
"Last saved title: " & locLastTitle

To edit a property, select the control, pick the property in the property dropdown on the left of the formula bar (the bar marked fx above the canvas), then type the formula. Studio shows an error until the variables exist; that’s fine for now.

gblSaveCount is a global variable (available on every screen), and locLastTitle is a context variable (this screen only). Our guide to global vs context variables explains when to pick each.

Checkpoint: the screen has the title box showing Replace keyboard, three buttons and two labels.

Step 3: Chain Multiple Actions in the Save Button’s OnSelect

Now the main part. Select btnOsSave, choose OnSelect in the property dropdown, and paste this formula:

Set(gblSaveCount, gblSaveCount + 1);
UpdateContext({locLastTitle: txtOsTitle.Text});
Notify("Saved: " & txtOsTitle.Text, NotificationType.Success);
Reset(txtOsTitle)
btnOsSave selected with OnSelect in the property dropdown and four actions chained with semicolons

Each line is one action, and the semicolon at the end of a line separates it from the next. Here’s what each one does:

  • Set(gblSaveCount, gblSaveCount + 1) adds one to a global counter. It starts blank, and blank + 1 gives 1.
  • UpdateContext({locLastTitle: txtOsTitle.Text}) stores the typed title in a context variable.
  • Notify(…) shows a green success banner with the title.
  • Reset(txtOsTitle) puts the box back to its Default value, Replace keyboard. It doesn’t blank it.

Order matters. Microsoft documents that actions run in the order they appear, and the next one doesn’t start until the current one finishes. That’s why Reset goes last: Notify has to read the title before it’s cleared. Need several variables in one go? See how to set multiple variables at once.

If an action fails, the ones after it might not run. So put the step that’s most likely to fail (such as a Patch to SharePoint) before the success banner, not after it.

Checkpoint: the formula bar shows four actions and no red underline.

Step 4: Run Another Button’s OnSelect With Select

Sometimes two buttons should do the same work. Instead of copying the formula, call it. Select btnOsAgain, pick OnSelect, and enter:

Select(btnOsSave)
Run Save again button with OnSelect set to Select(btnOsSave) in the Power Apps formula bar

Select acts as if the user clicked btnOsSave, so its whole OnSelect runs. Four rules from Microsoft are worth knowing:

  • Select queues the target OnSelect. It may run after the current formula finishes, and it doesn’t wait for it.
  • It only works on the same screen, never across screens.
  • The target must have an OnSelect property, and a control can’t Select itself, even through other controls.
  • You can use it only in behavior formulas such as OnSelect, not in Text or Fill.

Because of the queue, don’t put an action after Select(btnOsSave) that depends on Save’s result. If you need to stop repeat clicks while it runs, see how to disable a Power Apps button.

Checkpoint: btnOsAgain shows Select(btnOsSave) and no error.

Step 5: Open Another Screen With Navigate

The third button leaves this screen. Select btnOsGo, pick OnSelect, and enter:

Navigate(scrComments, ScreenTransition.Fade)

The first argument is the screen and the second is the transition: Cover, CoverRight, Fade, None (the default), UnCover or UnCoverRight. A third, optional argument passes a record of context variables to the new screen. Our Power Apps Navigate function guide covers screens in depth.

To come back, put Back() on a button on the other screen. It returns to the last screen with the reverse transition.

Checkpoint: btnOsGo shows the Navigate formula. Your app needs a screen called scrComments (any blank screen works).

Test the App

Select Preview (the play button at the top right) or press F5. Press Esc to return to the editor. You can also hold Alt and select a button while editing to run it without Preview.

I typed Monitor flickering in the box and selected Save request once. The banner read Saved: Monitor flickering, the labels showed Saves this session: 1 and Last saved title: Monitor flickering, and the box went back to Replace keyboard. That’s the screen at the top of this post.

Next I selected Run Save again. Save’s OnSelect ran a second time, with the reset title:

Preview after Run Save again with the banner Saved: Replace keyboard and Saves this session: 2
ClickWhat the app showed
Save request (typed Monitor flickering)Saved: Monitor flickering; count 1; box back to Replace keyboard
Run Save againSaved: Replace keyboard; count 2
Open comments screenscrComments opened; a global set there earlier (Printer jam on floor 3) was still shown

The last row shows why the counter uses Set: global variables keep their values when you move between screens.

Checkpoint: one click gives count 1, Run Save again gives count 2, and the banner text matches the box.

More OnSelect Patterns From Real Apps

These come up in almost every app I build. They aren’t on the demo screen, so treat them as formula patterns and swap in your own control and screen names.

Submit a form, then go to a thank-you screen

SubmitForm(frmRequest); Navigate(scrThanks, ScreenTransition.Fade)

This navigates even if the submit fails. A safer way is to put the Navigate in the form’s OnSuccess property. Our guide on how to submit a form to a SharePoint list walks through it.

Navigate based on a condition

If(tglConfirm.Value,
    Navigate(scrSuccess, ScreenTransition.Fade),
    Navigate(scrReview, ScreenTransition.Fade)
)

Inside If, the branches are arguments, so they’re separated by commas. You can still chain actions with semicolons inside one branch.

Create or update a SharePoint item

Patch('Service Requests', Defaults('Service Requests'), {Title: txtOsTitle.Text});
Notify("Request created", NotificationType.Success)

Defaults() creates a new item; pass an existing record instead to update one. The Patch function in Power Apps post covers both.

Run a Power Automate flow

Open the Power Automate pane on the app authoring menu, add a flow that has a Power Apps trigger, then call it from OnSelect:

NotifyServiceDesk.Run(txtOsTitle.Text)

With the pane enabled, adding a flow keeps your existing OnSelect formula. If you’d rather skip the flow for approvals, see how to send an approval email from a button.

Open a link, toggle text or close the app

GoalOnSelect formula
Open a web pageLaunch("https://www.spguides.com/")
Toggle a variableUpdateContext({locShow: !locShow})
Button text that follows itText: If(locShow, "Hide details", "Show details")
Edit the gallery’s item in a formEditForm(frmRequest); Navigate(scrEdit)
Clear a formResetForm(frmRequest)
Close the appExit() (Exit(true) also signs the user out)

For a full link button, see how to create a hyperlink button in Power Apps.

Change a Button’s Color When It’s Selected

The Button control has built-in properties for this, so you often don’t need a formula at all:

PropertyWhat it controls
PressedFill / PressedColorBackground / text color while the user taps or clicks
HoverFill / HoverColorBackground / text color while the mouse pointer is on it (by default the fill dims 20%)
PressedTrue while the button is being pressed, false otherwise (it isn’t a color)
Fill / ColorNormal background / text color

PressedFill only lasts while the click is held. To keep a button highlighted after it’s selected, store the choice in a variable and point Fill at it. For two buttons where only one can be active:

// btnCart.OnSelect
UpdateContext({locActive: "Cart"})
// btnBuy.OnSelect
UpdateContext({locActive: "Buy"})
// btnCart.Fill (use "Buy" on btnBuy.Fill)
If(locActive = "Cart", Color.RoyalBlue, Color.DimGray)

The same idea drives showing or hiding a button based on a condition: set a variable in OnSelect and read it in Visible. The newer Power Apps modern button control has a different set of style properties.

OnSelect on Galleries, Containers and Other Controls

Buttons aren’t the only controls with OnSelect. Microsoft lists it on icons, images, labels, shapes, check boxes, toggles, text inputs, charts and more, so an icon can run the same chained formula.

In a gallery, every control inside starts with OnSelect = Select(Parent). That passes the click up to the gallery’s own OnSelect. Our post on the Power Apps gallery OnSelect property shows the common Navigate-to-details setup.

Gallery OnSelect not working? Usually a control in the row has its own OnSelect, which replaces Select(Parent), or something sits on top of the row and catches the click. Set the child back to Select(Parent), or add your formula to the child directly.

Container OnSelect property: the Container control’s property list on Microsoft Learn has no OnSelect (it has Fill, borders, size, position and Visible). To make a whole card clickable, put a button over it with a transparent Fill and no text, or build the card in a gallery.

Make It Production-Ready

  • Turn on AutoDisableOnSelect so the button is disabled while its OnSelect runs. It stops double saves on slow connections.
  • Put risky steps (Patch, SubmitForm, flow runs) first and the success Notify last, because a failed action can stop the rest.
  • Name controls (btnOsSave, txtOsTitle) before writing formulas. Select, Reset and Navigate read much better that way.
  • Validate inputs inside any flow you call. Microsoft notes that arguments from Power Apps to Power Automate are visible as network traffic.

Troubleshooting

  • Only the first action runs. A semicolon is missing between actions, or an earlier action failed. Check the formula bar for red underlines and test each action alone.
  • Semicolons don’t work. In languages that use a comma as the decimal separator, Studio uses ; between arguments and ;; between actions.
  • Reset left text in the box. That’s by design: Reset restores the Default value. Set Default to "" if you want an empty box.
  • Reset does nothing on a gallery or form control. You can’t reset controls inside a gallery or edit form from outside it. Use ResetForm for forms.
  • Select does nothing. The target is on another screen, or it doesn’t have an OnSelect property.
  • The button does nothing in the editor. Clicking in Studio selects the control. Hold Alt while you click, or use Preview.

Where to Take It Next

If you’re adding more buttons to your app, these walkthroughs are a good next read:

Frequently Asked Questions

How do I run multiple actions on one Power Apps button?

Put all of them in the button’s OnSelect property and separate them with semicolons, for example Set(gblSaveCount, gblSaveCount + 1); Notify(“Saved”); Reset(txtOsTitle). They run in the order you write them.

Does a Power Apps container have an OnSelect property?

No. The Container control lists Fill, border, size, position and Visible, but not OnSelect. Place a transparent button over the container, or use a gallery, which does have OnSelect.

How do I change a Power Apps button color when it’s selected?

Use PressedFill and PressedColor for the moment of the click and HoverFill for mouse-over. To keep the color after the click, set a variable in OnSelect and use If() on that variable in the Fill property.

Why is my gallery OnSelect not working?

A control inside the gallery probably has its own OnSelect instead of the default Select(Parent), or another control covers the row. Restore Select(Parent) on the child control, or move your formula there.

Can one button run another button’s OnSelect?

Yes, with Select(ButtonName) on the same screen. The target formula is queued, so it may run after the current formula ends. See the Select function reference and the Button control reference on Microsoft Learn.

3 thoughts on “Power Apps Button OnSelect: Run Multiple Actions in One Click (Build Along)”

  1. Hi Bijay, thank you for this article, very helpful for beginners like me. However, I have a simplest question about multiple functions for one button. I find everywhere information about putting “;” sign between commands but it doesn’t work for me!

    My code for OnSelect: Collect(
    Requests;
    {
    Requestor: Orderby.Text;
    Email: Email_2.Text;
    Executive: Director.Text;
    Priority: Dropdown1.SelectedText;
    Message: TextInput1.Text
    }
    )
    ;
    Navigate(ConfirmationRequestScreen;Fade);

    But has to create a new item for collection (gallery) Requests and set next screen, however I see an error “Unexpected sign”.

    Can you please advise what I am doing wrong?

  2. How is PowerApps button onselect change dropdown different from PowerApps button onselect update sharepoint list? I have set up buttons for the first example but my drop down values don’t update correctly. I do need to update the SharePoint list as well, but I’m unclear about whether a combo box is required for the second example or not.

Leave a Comment