Getting department (and other profile information) of a user in PowerApps

Cloudatica
3 min readJun 10, 2021

--

In enterprise PowerApps, a very common requirement is to retrieve information like department name, title etc about a user. 2 common use cases for user information like Department and Title are:

  • Just display that information in your app e.g. silly example app below shows display name and department of the sign in user or for the user email that user types:
  • Another use case could be implementing some security features e.g. limit some features to the users of certain departments or show filtered information for the department of the user.

Some of you might think that since this information is in Active Directory, you’ll need to use some complex concepts like custom connector with Graph API, like I mentioned in this video and this article. Good news is that for simple scenarios like getting department, displace name etc, you don’t need to use those complex concepts. A simple connector provided by PowerApps- Office365Users is good enough.

Implementing this is very simple using a PowerApps connector called Office365users. This article shows you how to do. If you prefer video tutorial, here is:

Getting display name and department of the signed in user

In your PowerApps, add Office365users connector:

After adding this, add a label control in your PowerApps and put the following formula in the default property of this label control:

“Hello “ & User().FullName & “, your department is “ & Office365Users.MyProfile().Department

Things to note in this formula are:

  • User() is an object that PowerApps gives you out of box. You don’t even need to add any connector for this. User().FillName gives you full name of the signed in user. BTW- Another useful property of User() object is email. You can get this with the formula — User().Email.
  • Office365Users.MyProfile() gives the profile of the signed in user. If you do dot of this, you’ll get different profile information that you can use. For the use case at hand, we are selecting Department property. So, Office365Users.MyProfile().Department gives the department of the signed in user.
  • Rest of the formula uses string concatenation in PowerApps.

Getting display name and department of any user in your organization

In the earlier section, we found the information of the signed in user. But, what if you want to get department information of any user in your organization? For doing this, use the similar concept.

First add Office365Users connector, like we did in the last section. For getting the information of any user, just modify the formula to use UserProfile() instead of MyProfile():

“Department of “ & Office365Users.UserProfile(TextInput1.Text).DisplayName & “ is “ & Office365Users.UserProfile(TextInput1.Text).Department

That’s all it is to implement this feature.

Final thoughts

As you can see, PowerApps has many powerful capabilities and out of box connectors like these to implement useful features like this.

If like articles like these, please subscribe to us on Medium and Youtube. For Training, 1:1 coaching, or Consulting help on Power Platform, Azure, or Data Science, please email us at hello@cloudatica.com or book a session at cloudatica.com .

--

--

Cloudatica

Team of experts in Microsoft AI Stack (Copilot) and Power Platform. For consulting or training, reach out to us at hello@cloudatica.com