Showing results for 
Search instead for 
Did you mean: 

How to Create UserName & UserID to improve Access Control

Assuming that you sign in PowerApps with a WorkMail, in your dept. but you have few users, and you wish to control who use the apps, access right, etc.


Though this may not be a good idea due to data security, but it is a way of designing control right.


Here I wish to share on how to create:

- UserName


- UserID


so as to control who can actually use / access the apps, especially navigation to those Screens confidential to particular users.

Meantime, you may also Save the UserName to trace the last sign in user.


  1. Let say you have a database with UserName and UserID

[In this case, I manually create one and show at the bottom of the age]


  1. Insert a Dropdown (name it as DDUserName) and tie it to:

Dropdown. Items

= Distinct(Passkey, UserName)


  1. Insert a TextInput box to enter UserID: Name it as TextUserID


  1. Insert a TextBox (or any other Icon, Button, etc.) with message to show up when UserName & UserID match each other.


So, please set the Visible of the TextBox to:




= If(LookUp(Passkey, UserName = DDUserName.Selected.Result).UserID = TextUserID.Text, true, false)


The formula above says:

  1. LookUp the Table called Passkey, and if the UserName is same as UserName selected from Dropdown, check if the corresponding UserID match the TextInput data (as in TextUserID).
  2. If Yes, true – it will become Visible = true and show up. Otherwise, it will be ivisible.


Hope this simple formula will hlep to create PassKey by modifying my sample here.




Screenshot (84).pngSample UserName & UserIDScreenshot (85).pnguserName.UserID = TextInputScreenshot (86).pngUserName <> UserIDScreenshot (87).pngUserName.UserID = TextInput


Below Screenshots are the actual apps I have modified to use Number Key to suit today's trend. Just sharing.


Screenshot (88).pngAccess Key Pad No,Screenshot (89).pngBoss match with User ID..All Access Show-UpScreenshot (90).pngAccess Control for employee.





Great idea! I would do it slightly different though, via the help of a settings table in your database and User().Fullname.


The advantages of this is that the users don't need to handle yet another password/passcode and the user also doesn't get the feeling that there are hidden things they cannot see, and they don't need to select their own name. Also, you don't need to add the administration burden of resetting the password if needed, but instead you would have to set each user's access flags. 


I would create a new table in the database, in this example called SECDB, containing all the settings your app needs, probably through bit-fields, and the user's full name as the key.


When the app starts, in the main form's OnVisible, do a lookup and save the settings in a record so you don't have to repeat the lookup all the time (unless of course, the settings change often):

UpdateContext({rUserSettings:Lookup(SECDB; User = User().Fullname)})


Now, in the textbox (or any other control), set the visible flag according to the settings in the user's record: 


TextBox.Visible: rUserSettings.ShowTextbox = true

Let's say there's a menu with administrator functions, show or hide it with something like below:


mnAdmin.Visible = rUSerSettings.IsAdmin = true

If would be even better if it was possible to add on the security settings in the built in User account, hence drop the need of an extra table. 


Hope this makes sense 🙂

Meet Our Blog Authors
  • PowerApps Community Mentor 2018, Practicing surgeon and former Professor of Surgery, University of Illinois, Chicago.
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 12 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • My name is Timothy Shaw and I create digital solutions using the Power Platform, Office 365, and Azure SQL and handle the IT for a small company in the energy sector. When not building the future :), I enjoy playing guitar, good (or really bad!) sci-fi, Xbox therapy, and hanging with my wife and son. Twitter: @ShortForTim