web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Unable to Hide Custom ...
Power Apps
Suggested Answer

Unable to Hide Custom Command Bar Button Based on User Role in Model-Driven App

(0) ShareShare
ReportReport
Posted on by 6

Hi Team,
I have created a custom “Create Copy” button on the form in our Model-Driven App.



Requirement:
The button should be visible only to System Administrator users
The button should be hidden immediately when the form loads for non-admin users
Non-admin users should not see the button at all

What I Have Tried:
Checked the Visibility option in Command Designer
Only “Show” option is available
No Power Fx (fx) option is visible
Tried using JavaScript to control visibility
Not possible to properly hide modern command bar button on load
I have implemented a JavaScript role check on the button click. However, this logic only runs after the user clicks the button.

Right now, the button is visible to all users, but non-admin users are blocked only after clicking it.

However, the requirement is that the button should be hidden completely when the form loads, so non-admin users should not see it at all.
Is there anyway to hide the button on page load based on user role?
Do we need Power Fx for this, or is Ribbon Workbench the only option?
We are using Modern Command Designer, and the Visibility section only shows “Show” with no Power Fx or custom rule option available.

Thank you.

Categories:
I have the same question (0)
  • Suggested answer
    Sunil Kumar Pashikanti Profile Picture
    1,353 Moderator on at
     
    Did you follow the below steps:
    Open your app in the app designer, go to the table's pages, click the three dots (...), and select Edit command bar.
    If prompted, ensure you select Power Fx as the commanding option. This creates a component library that stores your formulas.
    Set Visibility Rule:
         Select your "Create Copy" button.
         In the Visibility dropdown on the right pane, change it from "Show" to "Show on condition from formula".
    In the formula bar at the top, select the Visible property and enter a formula that checks for the user's role.
     
    Since User() function support can be limited in some model-driven environments, a common approach is to check for a specific privilege that only System Administrators have, such as the ability to read all security roles.
    // Example: Hides button if user cannot see 'System Administrator' role details
    !IsBlank(LookUp(SecurityRoles, Name = "System Administrator"))
    Alternatively, if your environment supports it, you can check for the role name directly by looking up the current user's email in the Security Roles table.
    // Hides button for everyone except 'System Administrator'
    "System Administrator" in LookUp(Users, 'Primary Email' = User().Email).'Security Roles (systemuserroles_association)'.Name
     
     
     
    ✅ If this answer helped resolve your issue, please mark it as Accepted so it can help others with the same problem.
    👍 Feel free to Like the post if you found it useful.
     
  • CU08100545-1 Profile Picture
    6 on at
    Thank you for the suggestion. Unfortunately, our environment does not show the Power Fx option in the Command Designer — the Visibility section only shows “Show” with no formula option. Is there any way to enable Power Fx visibility in this environment, or should we use Ribbon Workbench instead?
  • Sunil Kumar Pashikanti Profile Picture
    1,353 Moderator on at
     
    How to enable Power Fx visibility in the Command Designer

    Open the app in the modern app designer
         Solutions → open your solution → select the model‑driven app → Edit (modern designer).
         From Pages, choose the table → … → Edit command bar → pick location (Main form / Main grid / Subgrid).
         The first time you add a modern command, pick Power Fx (this creates the command component library).
    Create a new custom command (don’t try to edit OOB)
         OOB (classic) commands cannot be edited in the modern designer; you can add new commands, but to change OOB visibility you still need classic tools (Ribbon Workbench).
    Set visibility with a formula
         Select your new command → in the right properties pane under Visibility, choose Show on condition from formula → you’ll get the Power Fx formula bar for Visible.
     
    If the formula option still doesn’t appear
         Confirm you are not on an OOB command. Try New → Command and check Visibility again.
         Open the command via the component library. In Solutions, open the Command Component Library entry and ensure it loads; sometimes adding data sources there (see next section) “unlocks” the experience. [forwardforever.com]
     
    If the above does not help or you specifically must hide/override OOB commands, then use Ribbon Workbench (XrmToolBox) to apply classic Enable/Display rules or JS. It remains the most reliable approach for OOB buttons.
     
    Let us know if it helps!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 536

#2
WarrenBelz Profile Picture

WarrenBelz 426 Most Valuable Professional

#3
Haque Profile Picture

Haque 305

Last 30 days Overall leaderboard