cancel
Showing results for 
Search instead for 
Did you mean: 
happyume

How To get Dataverse User record for current logged in user

The User() function within Power Apps  returns a record about the current user but that information is not currently connected to the systemuser table within Dataverse instance of the environment.  User() Function returns email, fullname, image and since around Sep 2023, it is also returning Azure Entra ID of the current logged in user.

 

For many situations, it is necessary to obtain current user record from the systemuser table within Dataverse. One of the ways to get is by using email as a lookup field:

 

 

LookUp(Users, 'Primary Email'=User().Email)

 

 

 

This would work for most of the organization, however this 'Primary Email' also known as internalemailaddress is available for update (IsValidForUpdate =true) thus creating a risk of accidental updates and hence the above LookUp not performing as expected. Similarly, for many large organizations, there is possibility that users have subdomains in their User().Email or under internalemailaddress, and they may not match each other.

 

A much more robust way to handle all possible such situations is to use Entra ID of the current logged in user as below:

 

 

LookUp(Users,'Azure AD Object ID' = User().EntraObjectId)

 

 

 

This way any accidental changes or presence of subdomains will not alter the output of the LookUp formula.