Manage Custom Role Based Permission In PowerApps Using SharePoint List

Introduction

In this blog, I have explained how to create a custom role permission to control the UI elements based on SharePoint List Configuration.

Open the SharePoint site to create a custom Sharepoint list to manage roles and user information like the below screenshot.

ColumnName DataType
UserName Person or Group 
Role Single Line Of Text
Status Yes / No

Open  PowerApps Portal  Sign in using a Valid Microsoft account,

Step1. After successful login, Navigate to Create from left navigation -> New App -> Blank Canvas App -> Click Create.

permission in PowerApps using SharePoint List

Step 2. Provide the App Name  -> "UserRoleDemo" Choose tablet or phone as your choice, then click the "Create" button.

permission in PowerApps using SharePoint List

Step 3. On the screen, create two buttons named "Administrator" and  "User".

permission in PowerApps using SharePoint List

Step 4. Click on the "App" from the left navigation -> Choose the "OnStart" action from the top dropdown.

permission in PowerApps using SharePoint List

Step 5. Click on the DataTab  -> Click New Connection -> Connector, choose SharePoint, then choose the relevant SharePoint site that holds the data and choose the respective custom list like the below screen.

permission in PowerApps using SharePoint List

Step 6. Create a User variable to store the currently logged-in user information, then create a collection to store the user role information.

In the below expression, I have extracted all the active role items related to the currently logged-in user.

Set(varUser, User());
Set(varUserManager, User().Email);
ClearCollect(UserInformation, Filter(UserRole, 'UserName'.Email = varUser.Email && Status = true));
Set(isStandardUser, !IsBlank(LookUp(UserInformation, "User" in 'Role' )));
Set(isAdmin, !IsBlank(LookUp(UserInformation, "Administrator" in 'Role')));

Once you successfully applied the above expression.

Step 7. Click the "Administrator" button to choose the "Visible" event from the top dropdown pass the variable isAdmin.

permission in PowerApps using SharePoint List

Step 8. Do the same thing for the other button and update the variable "isStandardUser".

permission in PowerApps using SharePoint List

Once you apply the logic, you can see the button has been hidden for the User button has been hidden for the administrator.

Conclusion

The blog explains how to create a custom role permission in PowerApps to control UI elements based on SharePoint List Configuration. It involves creating a custom SharePoint list, creating a PowerApps app with two buttons, connecting to the SharePoint site, creating a user variable, and creating a collection to store the user role information. The article provides step-by-step instructions to filter and extract active role items related to the currently logged-in user and shows how to hide buttons based on the user's role.

Happy Coding !....