Using power apps command editor. How to check the user security roles before displaying a button in the command bar.
This command is displayed on a page inside Dynamics 365 sales.
Here is my formula:
!IsBlank(Self.Selected.Item.'FieldX') &&
!IsBlank(Self.Selected.Item.'FieldY') &&
!Self.Selected.Item.AlreadyDone &&
/* Some code to check that the user has security role 'X' */
Is there a way to verify the user security rôle in a Visibility Formula?
I tried to use the User function and also tried other functions such as UserRoles and Roles but there is no function with those names that seems to be defined.
I was missing a few parts. First I had to open the command in the Components Library when editing the commands in Power Automate.
Then I had to add two connections. The 'Users' and 'Security Roles'.
Since my command is in a solution, I also had to add to add those two tables in the solution.
After that, I could query the tables in the formula text box. I came up with something like this:
!IsBlank(LookUp(LookUp('Rôles de sécurité', Nom="X").Utilisateurs,'Nom d''utilisateur'=User().Email).'Nom d''utilisateur')
PS. Sorry, the Power Automate I used is in French. If you encounter this problem you can figure the tables and properties names yourself.