Hello all!
I am building a model-driven app and was playing with the command bar to create a custom button. It's a really nice feature and the Action/OnSelect action seems to be working fine, however the Visibility/Visible formula doesn't work.
I tried this in a canvas app and it works fine. I am checking to see if the logged in user has the "System Administrator" security role assigned to them. If it does, then show the button otherwise hide it.
If(
CountRows(
Filter(
LookUp(Users,domainname =User().Email).'Security Roles (systemuserroles_association)'
,Name="System Administrator"))>0
,true,false)
I lookup the logged in user record in the "User" table, access the relationship table between User-Security Role called "systemuserroles_association" to see all the related security roles to the user which returns a table. Then I filter that table on the Name of the security role to be "System Administrator" and count the rows to check if it has more than 0. It should have one row if the user has "System Administrator" which then makes the condition true.
Any other advice on how to achieve this? I cannot put any JavaScript in the Visibility formula either.
I was thinking of creating the button with the Ribbon Workbench but that might have issues of its own.
Thank you!