The User function can retrieve the logged-on users Full Name, Email and Photo:
Seems straight forward enough, doesn’t it?
As good as it might appear on the surface, the Microsoft documentation says the outputs may not match the current user’s information in Microsoft 365 or other services:
You don’t have to look too far to find evidence of this either (here and here being such examples). I believe the outputs of the User function comes from the ‘Users’ table in the CDS, which is synced data from Office 365. However, in my experiences of using this I’ve found mismatches with user names, emails and user principal names, or sometimes the user isn’t even found. There is a workaround for mismatches by using the Lower function; to avoid that or any of the above, I’ve defaulted to use the ‘Office 365 Users‘ connector instead.
Office 365 Users connector
Here’s why it’s better and safer to use this connector to get logged-on user information:
** It’s looking at your Office 365 user profile, which is tied to your company’s Active Directory. Active Directory should be sole version of truth for user data.
** Does your company have other third party systems you use? Chances are they’ll be implementing Single Sign On and to do that, user information syncs with Active Directory. That means any filtering of user information in other systems will be far more accurate if using this method.
** The outputs are considerably richer in information. The Office 365 profiles can hold other pertinent information, such as Department or Line Manager, the latter being awesome for automating escalations or approvals. It opens up more possibilities for conditional visibility, automations and other cool things.
** The connector exposes lots of other API endpoints, such as searching for other users or getting your direct reports.
** When trying to retrieve user information in Power Automate, what connector do we typically use? The Office 365 Users connector. Using the same in Power Apps is therefore a more consistent approach.
Configuration and approach
I’ll outline the steps and my approach below in this section.
Firstly add the Office 365 Users connector to your app:
Then, in the OnStart property for the app, I’ll add the following Power Fx to store the logged-on users information and profile image. Doing it this way means you only call the API once per session.
/* Set global variables for logged-on users M365 profile details */ Set( gvUserProfile, Office365Users.MyProfileV2() ); Set( gvUserProfileImg, Office365Users.UserPhotoV2(gvUserProfile.mail) )
NOTE: there are 2 versions of each. Always opt for the latest version – in this instance that’s the V2 options.
You can now use the variable in any of the usual ways in your app. You can see from the IntelliSense the breadth of data available:
If you want unrivalled accuracy for user data in the Power Platform, it’s the Office 365 Users connector all the way.