Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Hide command bar buttons based on security role

(2) ShareShare
ReportReport
Posted on by 8

I have created custom buttons using the Command Bar designer. How do I hide certain buttons from certain security roles using the PowerFx formulas?

 

I have tried using the Ribbon Workbench XRM tool but when I load the solutions, these custom buttons are not showing in RIbbon Workbench.

 

So I guess my only option is to use PowerFx formulas on the Command Bar designer to hide buttons depending on the user's role. Can anyone help me work out how to get the user's security roles and hide the button from them?

  • moasmar Profile Picture
    moasmar 17 on at
    Hide command bar buttons based on security role
    @mjburley Thank you this worked, but after checking the docs, it should be used in this format:
    RecordInfo( First(Accounts), RecordInfo.EditPermission )
    because initially I was using only RecordInfo.EditPermission then it stopped working properly. 
  • shameervalappil Profile Picture
    shameervalappil 22 on at
    Re: Hide command bar buttons based on security role

    Thanks for the clue.. I made it work with minor modification to your formula as below;

     

    RecordInfo(Self.Selected.Item,RecordInfo.EditPermission) -  On command Bar Visible property

  • mjburley Profile Picture
    mjburley 370 on at
    Re: Hide command bar buttons based on security role

    There are permissions support for this in preview (Permissions support in DataSourceInfo and (new) RecordInfo functions for Dataverse | Microsoft Power Apps), which did not work well months ago, but probably worth trying again. Examples to try in the visible property of the command bar:

    For a table:

    If(DataSourceInfo.CreatePermission,true,false)
     

    For a particular record

    If(RecordInfo.DeletePermission ,true,false)
    so the user would presumably need the delete role on that record for example (also editPermission and readPermission).
     
    I did just try them out of curiousity and they enter all fine with no red squigglies, but just do not seem to work. Both an admin and normal user either sees or does not see depending on delete role.
     
    Maybe I have cache issues or not quite doing it right, so please try yourself. Just make sure to try with both cases.

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,475

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,767

Leaderboard