using the Modern Command Bar, you cannot control button visibility based on a user’s security role (e.g. “Area Manager”).
This is because Power Fx used in Modern Commanding does NOT support accessing the current user or their security roles, and functions like User() do not work at runtime for command bar visibility logic even though they may appear to return values inside the component library editor.
This limitation is confirmed in Microsoft’s documentation for Power Fx commanding.
Use Power Fx with commands - Power Apps | Microsoft Learn
Supported ways to control visibility today
1) Modern Command bar, use Power Fx privilege checks permission level on table or record like below formula
Show button only if user has Create permission on Accounts
DataSourceInfo(Accounts, DataSourceInfo.CreatePermission)
Shows button only if user has Edit privilege on the selected record:
RecordInfo(Self.Selected.Item, RecordInfo.EditPermission)
other permisson check available like :
RecordInfo(Self.Selected.Item, RecordInfo.ReadPermission)
RecordInfo(Self.Selected.Item, RecordInfo.DeletePermission)
RecordInfo(Self.Selected.Item, RecordInfo.AssignPermission)
This does not check the role explicitly but checks permissions that the user inherently has
2) If you MUST check the actual Security Role, You cannot do this in Modern Commanding, because role evaluation requires current user access (unsupported).
Instead, you must use:
Classic Ribbon Display Rule -> Role Rule
Classic ribbon supports role‑based visibility, which is the fully supported approach for this scenario.
Final take away : Modern commanding cannot perform this check based on security role name, you need to use Classic ribbon for full flexiblity on display rule.
Regards,
Manoj
✅If this answer helped you, please consider marking it as Verified, it really helps others in community