PowerApps Get Current User (ID, EMail, Department, Location, Photo, etc)

PowerApps get current user – In this PowerApps tutorial, we will discuss how to get current user details in PowerApps. Let us see, how to display SharePoint online site logged in user details like username, user id, and email address and display in a PowerApps screen or form.

Also, we will see these things as:

  • What is User function in Power Apps
  • How to get the current user in PowerApps
  • Get current user email Address in PowerApps
  • Get current user id in PowerApps
  • How to get PowerApps current user department
  • PowerApps get current user location
  • How to set current user Powerapps
  • PowerApps get current user profile
  • PowerApps current user photo or PowerApps current user image

User function in PowerApps

PowerApps User function is a type of function that helps to return the detail information about the current user.

Always this PowerApps User function returns the record details of the current logged in user. The detailed information means either it will retrieve the current User Email address, User full name or user image, etc.

NOTE:

PowerApps User function will match the Account information that is displayed in the PowerApps players and studio that can be found outside of any authored apps. This may not match the current user’s information in Office 365 or other services.

PowerApps User function Syntax

The syntax of PowerApps User function is:

User()

Below table represents some PowerApps user function properties with their descriptions as:

PropertyDescriptionOutput
User()This function returns all the information about the current user (in PowerApps).{ FullName: “Monika Singh”, Email: “monika123@tsinfo.com”, Image: “blob:1234…5678” }
User().EmailThis Powerapps function returns the email address of the current user (in PowerApps)“monika123@tsinfo.com”
User().FullNameThis Powerapps function helps to return the full name of the current user including the first and last name.“Monika Singh”
User().ImageThis function returns the image URL of the current user. But the image URL will appear with the form like “blob:identifier“. You can set the Image property of the Image control to this value to display the image in the app.“blob:5678…1234”

Check out more on PowerApps Image control.

PowerApps get current user

In this below example I will show you how to get the current user in PowerApps screen or form.

  • Sign in the PowerApps app with your credentials.
  • Create a blank new Canvas app and choose any one Layout either Tablet or Phone.
  • On the PowerApps Blank screen, take these below input controls as:
  1. Insert one Label control (Insert -> Label) and rename it to lblUserName.
  2. Add one Text input control (Insert -> Input -> Text input) and rename it to txtUserName.
  3. Select the text input control (txtUserName) and set its Default property as:
Default = User().FullName

Save and Preview (F5) the app. Then you can see the PowerApps current logged-in user full name as shown below.

PowerApps get current user

PowerApps get current user email

  • Similarly, you can retrieve the current user email address of the logged-in user (in PowerApps).
  • In the same way, On the PowerApps screen, insert a Label for UserEmail and a Text input control to display the value.
  • Select the text input control and set its Default property as:
Default = User().Email

Save and Preview (F5) the app. Then you can see the PowerApps current logged-in user Email Address as shown below.

PowerApps get current user email

PowerApps get current user id

To get the current logged in user id in PowerApps, we need to do these below things as:

  • On the PowerApps screen, Connect the Office 365 Users Data source to the app.
  • Go to View tab -> Data sources -> Search Office 365 Users -> Add a new or existing connection as shown below.
PowerApps get current user id
  • Insert a Text input control to display the User ID. Select the text input control and apply this below formula on its Default property as:
Default = Office365Users.UserProfile(User().Email).Id

Once you will save and preview (F5) the app, then you can see the PowerApps the currently logged-in user Id as shown below.

PowerApps get current loggedin user id

PowerApps get current user department

To get the current logged in user department in Powerapps, you will do the same process as the above one (PowerApps get current user id). Just we need to update the Department value instead of the ID value.

  • In the same way, you will add the Office 365 Users Data source connector to the app.
  • Insert a Text input control and set its Default property as:
Default = Office365Users.UserProfile(User().Email).Department

When you will save and preview (F5) the app, then you can see the PowerApps current logged-in user Department like the below screenshot.

PowerApps get current user department

PowerApps get current user location

Similarly, You can easily get the current user location in PowerApps.

  • Add the Office 365 Users Data source connector to the app.
  • Add a Text input control that will display the user office location.
  • Select the text input control and apply this below formula on its Default property as:
Default = Office365Users.UserProfile(User().Email).OfficeLocation

Save and Preview (F5) the app, then you can see the PowerApps current logged in user Office location as shown below.

PowerApps get current user location

Set current user Powerapps

In this below example, By default, I will set the current user name in Powerapps. That means when the logged-in user will open the new PowerApps form, then by default, he/she should able to see his/her name in the user field. Let’s have a look at how we can do these things.

  1. Title: By default, this is a single line of text data type column present in the list.
  2. User Name: This is a Person Data type column that I have created.
  3. Creator Name: This is a Single Line of text data type column.
Set current user Powerapps

On the Powerapps screen, do these below things as:

  • Add Office 365 Users data source connector to the app.
  • Connect the SharePoint Data source and add the SharePoint Online list (Default User Selection). Go to View tab -> Data Sources -> Search SharePoint -> Add a new or existing connection -> Select the SharePoint Site -> Choose the specific SharePoint List (Default User Selection) -> Hit on the Connect button. Then the specific SharePoint list will be added as shown below.
Set current user in Powerapps
  • Insert one PowerApps Edit form (Insert -> Forms -> Edit) and Insert the SharePoint list data source to it.
  • Then you can see the edit form will appear with these below fields. Just unlock all the Data card values from the edit form.
Powerapps Set current user
  • Next, Select the People picker field (User Name) and apply this below formula on its Default property as:
Default = {
    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    DisplayName: User().FullName,
    Claims: "i:0#.f|membership|" & Lower(User().Email),
    Department: "",
    Email: User().Email
}

Refer the below screenshot.

How to set Powerapps current user
  • Similarly, add the same formula on fields (User Name) DefaultSelectItems property as the below screenshot.
Powerapps set default current loggedin user
  • Now, you can see the PowerApps current logged-in user name will appear in the User Name field. When the user will open this edit form, then by default, he or she can able to view his/her name in the User Name field.
Powerapps set default current user
  • Similarly, if you want to set the full name of the Creator, then select the Creator Name field and set its Default property as:
Default = User().FullName
set default current user in PowerApps
  • Just save and preview the app, By default, You can see the current logged in user name in the User Name field and as well as in the Creator Name field.

PowerApps get current user profile

In this scenario, We will see how we can get current user profile in PowerApps. This is also known as PowerApps Auto Fill User Profile Details.

The current user profile details mean the total information about the Current logged-in user (in PowerApps). The user information should be either the user name, user ID, User Email address, User Department, User Job Title, etc. All these user information things we should get in one PowerApps form. Follow these below steps to do so:

  • I have created a SharePoint Online list named Employee User Profile. This list has these below columns as:
  1. Title: By default, it is a single line of text Data type
  2. Employee Name: Person or Group Data type
  3. Employee ID: Single line of text Data type
  4. Employee Email: Single line of text Data type
  5. Department: Single line of text Data type
  6. Job Title: Single line of text Data type
PowerApps get current user profile
  • Go to the PowerApps Canvas app.
  • Connect the Office 365 Users Data source connector to the app.
  • Connect the SharePoint Data source and add the SharePoint Online list (Employee User Profile).
PowerApps get current loggedin user profile
  • Insert one PowerApps Edit form and add the SharePoint list Data source on to it. Then the form will appear with these below fields as shown below.
  • Next, Unlock all the Data card field values.
how to get current user profile in PowerApps
  • Now its time to set the user information details to each field. Let’s see how to apply the formulas to each control in the edit form.
  1. Title: Here, you need to enter the values before submitting the form.
  2. Employee Name: To get the user name, just repeat the same steps from the above example (Set current user Powerapps)
  3. Employee ID: To get the current employee ID, Select the Employee ID field, and apply this below formula on its Default property as:
Default = If(Form1.Mode = FormMode.New, Office365Users.UserProfile(User().Email).Id ,Parent.Default)

4. Employee Email: To get the current employee Email Address, Select the Employee Email field, and apply this below formula on its Default property as:

Default = If(Form1.Mode = FormMode.New, Office365Users.UserProfile(User().Email).Mail ,Parent.Default)

5. Department: To get the current employee Department, Select the Department field, and apply this below formula on its Default property as:

Default = If(Form1.Mode = FormMode.New, Office365Users.UserProfile(User().Email).Department ,Parent.Default)

6. Job Title: To get the current employee Job Title, Select the Job Title field, and apply this below formula on its Default property as:

Default = If(Form1.Mode = FormMode.New, Office365Users.UserProfile(User().Email).JobTitle ,Parent.Default)
  • All these above values should be fetched from the connector only when the form is opened in New mode. Otherwise, it will display the saved value from the database.

Below screenshot represents for your reference.

Get current user profile in PowerApps

NOTE:

Not only the Office 365 Users connector have this much user information, but also it has many user profile details like City, Company Name, Country, Mobile Phone, Postal Code, Telephone Number, Surname, Business Phones, etc.
  • Save and Preview the app. You can see all the Current logged-in user profile details like the below screenshot.
Get current loggedin user profile in PowerApps

PowerApps current user photo or PowerApps current user image

Suppose you want to display the PowerApps Current Logged in Users photo in the PowerApps screen, then follow these below steps:

  • On the PowerApps screen, insert a Text input control and set its Default property to User().Image.
  • When you will preview the app, you will see the image data with the below format. Because when you will add the text input, it will retrieve the image text data, not the image.
PowerApps current user photo
  • To get the current user profile photo, we need to add an Image control on the Powerapps screen. So that we can easily view the image of Powerapps current logged in user.
  • Insert an Image control (Insert -> Media -> Image). Select the image control and apply this below formula on its Image property as:
Image = User().Image
PowerApps current user image
  • Also, you can apply this below formula to Image property to get the current user profile picture as:
Image = Office365Users.UserPhoto(Office365Users.MyProfile().Id)
PowerApps get current user image
  • Once you will save and preview the app, you can able to see the Powerapps current logged-in user profile picture as the above screenshot.

Also, you may like these below PowerApps Tutorials:

In this PowerApps Tutorial, We discussed how to get and display the current user details in the PowerApps screen or form. Also, we saw these things as:

  • What is User function in Power Apps
  • How to get the current user in PowerApps
  • Get current user email Address in PowerApps
  • Get current user id in PowerApps
  • How to get PowerApps current user department
  • PowerApps get current user location
  • How to set current user Powerapps
  • PowerApps get current user profile
  • PowerApps current user photo or PowerApps current user image
>