A command bar in Power Apps allows you to add custom buttons and actions to the top of a model-driven app's form or view, enabling users to trigger specific workflows, navigate to other pages, or run Power Fx formulas without leaving their current screen. To achieve this, you use the Command Designer within the Power Apps Studio to define which buttons appear, under what conditions they are visible, and what happens when they are clicked.

What You'll Need

  • A Power Apps environment with an active license.
  • A model-driven app already created (or a table you intend to use in one).
  • Appropriate security roles (System Customizer or System Administrator) to edit the app's command bar.
  • A basic understanding of Power Fx if you intend to use custom formulas for button logic.

Step-by-Step

  1. Open the App Designer: Sign in to the Power Apps portal. Select your environment in the top right corner. Go to the Apps section and select the model-driven app you wish to modify. Click Edit to open the App Designer.
  2. Access the Command Bar Editor: In the App Designer, locate the page or table where you want to add the button. In the left-hand navigation or the page settings, look for the option to edit the command bar. Note that labels may differ slightly by version or region; look for "Edit command bar" specifically associated with the table or the view.
  3. Select the Command Bar Location: You will be prompted to choose where the button should appear. You can choose between the "Main form" (the screen that opens when you view a single record) or the "Main grid" (the list view where all records are displayed). Select the appropriate location and click Edit.
  4. Create a New Command: Once the Command Designer opens, click the "+ New command" button. This will create a placeholder button on the bar. Give your command a clear, concise label (e.g., "Send Approval" or "Export Data") so users understand its purpose.
  5. Choose an Icon: Select an icon from the provided library that visually represents the action. Icons help users identify functions quickly without reading every label, improving the overall user experience.
  6. Define the Action: In the right-hand properties pane, locate the "Action" dropdown. You have three primary choices:
    • Run formula: This allows you to write Power Fx code to perform tasks like updating a field, sending a notification, or calculating a value.
    • Run JavaScript: This is for advanced users who want to call a custom web resource for complex logic that Power Fx cannot handle.
    • Run flow: This connects the button directly to a Power Automate cloud flow to handle backend processes like email distribution or integration with third-party software.
  7. Configure Visibility Logic: You do not always want a button to be visible. In the "Visibility" section, choose between "Always show," "Show on condition," or "Hide." If you choose "Show on condition," you can write a Power Fx formula. For example, you might set the button to only appear if the status of a record is "Draft" using a formula like Self.Selected.Item.'Status' = 'Status (Table)'.Draft.
  8. Test the Command: Use the "Play" button or the preview mode within the designer to ensure the button appears in the correct location and triggers the intended action.
  9. Save and Publish: Once the button is functioning correctly, click Save. To make the changes live for all users in your organization, you must click the Publish button in the App Designer.

Common Mistakes

One of the most frequent errors is forgetting to publish the app after saving the command bar changes. Because the command bar is part of the app's metadata, saving the command designer does not automatically push the changes to the end-user environment. Users will continue to see the old version of the bar until the app is published.

Another common mistake is creating buttons that are too generic. Labeling a button "Submit" when there are multiple submission types can confuse users. Be specific, such as "Submit for Manager Review." Additionally, developers often overlook the "Main Grid" vs. "Main Form" distinction. If you place a button on the Main Grid, it is designed to act on a selection of records; if you place it on the Main Form, it acts on the single record currently open. Attempting to use a single-record formula on a grid view will result in errors.

Over-reliance on JavaScript when Power Fx can do the job is also a common pitfall. Power Fx is integrated directly into the designer, making it easier to maintain and debug. Using JavaScript requires managing external web resources, which adds complexity to the deployment and versioning process.

Tips

To keep your command bar clean, use the "Visibility" settings aggressively. A cluttered command bar overwhelms users and increases the likelihood of accidental clicks. Only show buttons that are relevant to the current state of the record. For instance, a "Reopen Case" button should only be visible when the case is "Closed."

Leverage the Power Fx Notify() function when creating custom actions. This provides immediate visual feedback to the user (e.g., a small banner at the top of the screen saying "Record successfully updated"), which prevents them from clicking the button multiple times because they weren't sure if the action worked.

When working with the Main Grid, remember that you can create buttons that only appear when one or more records are selected. This is a powerful way to create "Bulk Actions," such as selecting ten records and clicking a custom "Bulk Approve" button to update them all at once via a Power Automate flow.

Troubleshooting

If your button does not appear after publishing, first clear your browser cache or try an Incognito/Private window. Model-driven apps heavily cache the command bar configuration, and you may be seeing a cached version of the interface.

If the button is visible but clicking it does nothing, check the Power Fx formula for syntax errors. If you are calling a Power Automate flow, check the flow's run history to see if the trigger was activated. If the flow failed, the button will appear to do nothing on the front end, but the error will be logged in the Power Automate portal.

If the visibility condition is not working as expected, verify the internal name of the field you are referencing. Power Apps is case-sensitive regarding logical names. Ensure you are using the correct schema name for the column rather than the display name. If the formula is complex, try simplifying it to "Always show" first to confirm the button itself is functional, then re-introduce the visibility logic step-by-step.

For JavaScript errors, open the browser's developer tools (F12) and check the Console tab. Any script errors, such as missing parameters or failed API calls, will be listed there. Ensure the web resource is published and the function name in the command designer exactly matches the function name in your JavaScript file.

Frequently Asked Questions

Can I add a command bar button to a Canvas App?

No, the Command Designer is a feature specifically for model-driven apps. In Canvas Apps, you must manually build your own navigation or action bar using Gallery or Button components.

How many buttons can I add to the command bar?

While there is no hard numerical limit, adding too many buttons will cause them to overflow into a "..." (More) menu. For the best user experience, keep your primary actions visible and move secondary actions to the overflow menu.

Can a command bar button open another app?

Yes, you can use a Power Fx formula to navigate the user to a different page or app using the Navigate() function or by triggering a URL launch.

Do I need to be a developer to use the command bar?

No, the modern Command Designer is a low-code tool. While JavaScript requires coding knowledge, most common tasks can be achieved using the visual interface and Power Fx formulas.

Can I change the order of the buttons?

Yes, you can rearrange the buttons within the Command Designer by dragging and dropping them or adjusting their sequence to ensure the most important actions are on the left.

Will custom buttons work on the mobile app?

Yes, custom command bar buttons are supported on the Power Apps mobile app, though they may appear differently (often tucked into the mobile menu) depending on the screen size and device.