How to get current login user role in canvas app – Role Based Navigation in Canvas APP
In many business scenarios, apps need to show or hide features based on the roles of logged-in users. Power Apps Canvas apps do not have built-in functionality to directly fetch user roles. However, with the right approach and integration with Microsoft Dataverse, you can implement Role-Based Navigation efficiently. This blog will guide you through achieving this.
Watch video below or scroll down the article to know more.
Key Objectives
- Understand how to retrieve the current user’s role in a Canvas app.
- Implement role-based navigation to control access and visibility.
Step 1: Setup in Dataverse
To retrieve user roles, you must ensure the required data is available in Dataverse.
Permissions
Ensure that the app’s service account has the necessary permissions to read these tables.
Table: Users and Security Roles
SystemUser: This table stores user information, including fullname
and systemuserid
.
Role: This table contains role details like name
.
SystemUserRoles: This table maps users to their roles. (Many to many intersect table between Roles and Users)
NOTE : You cannot use SystemUserRoles table in Canvas APP so you need to use powerfx for this. use below powerfx.
ClearCollect(UserRoles, (LookUp(Users,domainname = User().Email).’Security Roles (systemuserroles_association)’).Name)
Hope it helps.