You can use the visible property to hide almost any control on a PowerApps screen. I have an app where I check to see if the logged in user is listed in the admin list and if so, sets a global variable gvIsAdmin to true. Then I am hiding the last two rows of fields on the form if the user isn't an admin by setting the visible property of the datacards to gvIsAdmin.
So how you define and maintain the roles and users?
My app is leveraging a SP List to maintain an admin user table, and then I use:
If(CountIf(Role, User.Email = User().Email)>0, something true, something false) to control the behaviour of my app.
In my case I have a list called "PowerApps Roles" and each item in the list is a role (Title field) and each role item has a person field (Users) with a list of users in that role. Then on the start of my app I run this code to identifiy if the logged in user is in the admin role.
ClearCollect(colAdmins, LookUp('PowerApps Roles', Title = "Admins", Users));
Set(gvIsAdmin, !IsBlank(LookUp(colAdmins,Concatenate("i:0#.f|membership|", gvCurrentUser.Email) in Claims, DisplayName)))
*The reason I am using "Claims" instead of "Email" is because our tenant doesn't use the email address as the UPN and User().Email actually returns the UPN and not the Email address. For most tenants this doesn't matter because their Email and UPN are the same.
I don't recognize the screenshot. What type of PowerApp is this (Canvas, Model or Portal)?
Read the announcement for more information!
Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.
Features releasing from October 2019 through March 2020
Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications