PowerApps Search User

In this PowerApps Tutorial, we will discuss all the details about the Power Apps Search user and how you can get all the details about any user in PowerApps.

Also, we will cover all the below topics:

  • PowerApps Search User
    • PowerApps Get Current User Information
    • PowerApps Get another User Information
  • PowerApps Search Office 365 users
  • PowerApps Search Person Field
  • PowerApps Search Active Directory
  • PowerApps Search Email
  • PowerApps Employee Search
  • PowerApps Search User by job title
  • PowerApps Search Phone number
  • PowerApps Search User by Displayname

PowerApps Search User

  • PowerApps Search User, the name as it tells that how you can search any user details in PowerApps. Any of the user details means the user information like user ID, Display name, Phone Number, Department, Job Title, etc.
  • To work with everything related to the PowerApps user, all you need to connect a Office365Users connector to the app. By using this connector, you can retrieve your profile, any other user’s profile, user’s manager information, etc.
  • All the user realeted information, you can display in a Label control or you can filter a gallery control in PowerApps.

Also read: Power Apps Search Gallery + 19 Examples

PowerApps Get Current User Information

If you want to display all the information about the current logged in user, then simply take a Label control in the app and set these below formulas on its Text property (Depends upon what you want to retrieve):

FormulaDescription
Office365Users.MyProfile().CityThis formula helps to retrieve the city of the current user.
Office365Users.MyProfile().CompanyNameThis formula helps to retrieve the name of the company of the current user.
Office365Users.MyProfile().CountryThis formula helps to retrieve the country of the current user.
Office365Users.MyProfile().DepartmentThis formula helps to get the department of the current user.
Office365Users.MyProfile().DisplayNameThis formula helps to get the display name of the current user.
Office365Users.MyProfile().GivenNameThis formula helps to retrieve the given name of the current user.
Office365Users.MyProfile().IdIt helps to get the current user ID.
Office365Users.MyProfile().JobTitleIt helps to get the current user’s Job title.
Office365Users.MyProfile().MailIt helps to get the current user’s Email Address.
Office365Users.MyProfile().MailNicknameThis formula helps to retrieve the mail nickname of the current user.
Office365Users.MyProfile().mobilePhoneThis formula helps to retrieve the current user’s Mobile Phone number.
Office365Users.MyProfile().OfficeLocationThis formula gets the office location of the current user.
Office365Users.MyProfile().PostalCodeIt helps to get the Postal code of the current user.
Office365Users.MyProfile().SurnameIt helps to get the current user’s Surname.
Office365Users.MyProfile().TelephoneNumberThis formula helps to retrieve the current user’s Telephone number.
Office365Users.MyProfile().UserPrincipalNameThis formula helps to retrieve the current user’s Principal name.
Office365Users.MyProfile().AccountEnabledThis formula helps to enable the account of the current logged-in user.

This is how to get all the information about the current user in PowerApps.

PowerApps Get another User Information

Similarly, if you want to display all the information about another user, then insert a Label control in the app and set these below formulas on its Text property (Depends upon what you want to retrieve):

FormulaDescription
Office365Users.UserProfile(InfoAbout.Text).CityThis formula helps to retrieve the city of the other user.
Office365Users.UserProfile(InfoAbout.Text).CompanyNameThis formula helps to retrieve the other user’s Company name.
Office365Users.UserProfile(InfoAbout.Text).CountryThis formula helps to get the country of the other user.
Office365Users.UserProfile(InfoAbout.Text).DepartmentIt helps to get the department of the other user.
Office365Users.UserProfile(InfoAbout.Text).DisplayNameIt helps to get the other user’s display name.
Office365Users.UserProfile(InfoAbout.Text).GivenNameIt helps to get the given name of the other user.
Office365Users.UserProfile(InfoAbout.Text).IdIt helps to get the ID of the other user.
Office365Users.UserProfile(InfoAbout.Text).JobTitleThis formula helps to get the job title of the other user.
Office365Users.UserProfile(InfoAbout.Text).MailThis formula helps to get the email address of the other user.
Office365Users.UserProfile(InfoAbout.Text).MailNicknameIt helps to get the mail nickname of the other user.
Office365Users.UserProfile(InfoAbout.Text).mobilePhoneIt helps to get the other user’s mobile number.
Office365Users.UserProfile(InfoAbout.Text).OfficeLocationIt helps to retrieve the office location of the other user.
Office365Users.UserProfile(InfoAbout.Text).PostalCodeIt helps to retrieve the postal code of the other user.
Office365Users.UserProfile(InfoAbout.Text).SurnameIt helps to get the surname of the other user.
Office365Users.UserProfile(InfoAbout.Text).TelephoneNumberIt helps to get the telephone number of the other user.
Office365Users.UserProfile(InfoAbout.Text).UserPrincipalNameIt helps to get the user principal name of the other user.
Office365Users.UserProfile(InfoAbout.Text).AccountEnabledThis formula helps to enable the account of the other user.
Office365Users.UserProfile(InfoAbout.Text).BusinessPhonesThis formula helps to get the business phone number of the other user.

Where,
InfoAbout = you can specify an email address of the user in your organization. For example, Ronald@xyz.com

This is how to get all the information about the other user in PowerApps.

To know more, read this: PowerApps Get Current User (ID, EMail, Department, Location, Photo, etc)

In this scenario, we will discuss how to search PowerApps Office365 Users and filter results by Department?

  • In the below image, you can see there is a Dropdown control, a Gallery control, and a Text input control. So here I would like to filter the results by the user’s department (using a dropdown menu).
  • Suppose, if you select IT in the dropdown, then the Gallery will display only the people in the IT Department. Similarly, if you select FINANCE, then it will return people in the FINANCE department only, and so on.
  • As you can see, When I selected IT in the dropdown control, all the IT people appears in the gallery control.
PowerApps search office 365 users
PowerApps search office 365 users
  • Suppose, I want to search the people that are from the FINANCE department and also filter the user names that I want to view based upon the dropdown value.
  • That means, I selected the FINANCE and also entered the surname in text box, then the gallery will filter the user surnames those are present under the FINANCE department only.
Power Apps search office 365 users
Power Apps search office 365 users
  • To achieve this, we needs to do these below things:
  1. In the Dropdown menu, insert the departments on its Items property as:
Items = ["IT", "HR", "FINANCE"]

You can specify all the departments that you want to view in the Dropdown control.

PowerApps search office 365 user
Search office 365 users in Power Apps

2. Next, select the gallery control and apply the below code on its Items property as:

Items = Filter(
    Office365Users.SearchUser({searchTerm: txtEnterName.Text}),
    Department = ddDepartments.Selected.Value
)

Where,

  • txtEnterName = Text input control name
  • ddDepartments = Dropdown control name

Before applying the formula, you have to ensure to connect the Office365Users connector to the app, otherwise, you may get an error in the code.

search office 365 users in PowerApps
search office 365 users in PowerApps

NOTE:

  • By default, the PowerApps SearchUser function only returns 100 results, so if it’s possible, for example, that you have more than 100 Jack’s in your company, but only 10 of them in the HR department, this may not return all of them.
  • In this case what you can do is to increase the number of users that are returned by the SearchUser, using the expression below: (the code you will write in gallery’s Items property)
Items = Filter(
    Office365Users.SearchUser({ searchTerm: txtEnterName.Text, top: 500 }),
    Department = ddDepartments.Selected.Value)

The above code will return the first 500 Jacks’ in your directory, which will then be filtered by their departments.

This is how to work with PowerApps search office 365 users.

Also, read: Get users from Office 365 Group in PowerApps

Do you want to filter based on the display name of the person or group field in PowerApps?

  • To work with the SharePoint Person or People picker field, we will use the PowerApps Search function. So whenever we are using the search function, we need to add a column with a display name as a text field.
  • The reason is that the search function only works for the single line of the text type field. Other data types are not supported.

Follow the below scenarios to understand better.

Example – 1:

  • The below screenshot represents a Sharepoint List named TSInfo Attachments. This list has some various kinds of columns like Single line of text, Number, Choice, etc. Among them, there is a Person field called Book Author.
  • Now in PowerApps, I would like to search the text box using this person field and the gallery will filter based upon the person value.
PowerApps search person field
PowerApps search person field
  • For example, if the text input box is blank, then all the Sharepoint records will appear in the gallery control. If I will search any specific person display name, then the gallery will filter and display that specific person record details as shown below.
PowerApps search people
PowerApps search people
  • To do so, select the gallery control and apply the below code on its Items property as:
Items = Search(
    AddColumns(
        'TSInfo Attachments',
        "displayname",
        'Book Author'.DisplayName
    ),
    txtEnterPeople.Text,
    "displayname",
    "Title"
)

Where,

  1. TSInfo Attachments‘ = SharePoint List name
  2. displayname” = Specify the new column name
  3. ‘Book Author’.DisplayName = As it is a SharePoint Person field, so we need to provide it with .DisplayName
  4. txtEnterPeople = Text input control name where we can search the person name
  5. Title” = SharePoint single line of text field name
PowerApps search person
PowerApps search person

Example – 2:

In this scenario, we will discuss how to show a SharePoint List Person field in a PowerApps label control.

  • There is a Gallery control where all the records are retrieved from the SharePoint list named TSInfo Attachments. Here what I want to do is, when a user will select any record from the gallery, then the label will display of that related specific person name.
  • For example, when I clicked on the Power BI Reports from the gallery, then the specific book author name displayed in the label as shown below.
PowerApps search person column
PowerApps search person column
  • For this, select the label control and apply the below code on its Text property as:
Text = "Book Author: " & galAttachments.Selected.'Book Author'.DisplayName

Where,

  1. Book Author: ” = This specifies the string that will display in the label control
  2. galAttachments = Gallery control name
  3. ‘Book Author’.DisplayName = Specify the SharePoint person field name. As it is a people picker column, so we need to specify this field name with .DisplayName. Not only display name, but also you can specify with .Email, .Department, .JobTitle, etc. that you want to view in the label.
Power Apps search person

This is how to work with the PowerApps search person field.

Do you want to get Azure AD Directory Users within your PowerApps? Check out the below example to know more details.

  • In the below screenshot, you can see there is a search box where the user will enter their Azure ID and then tap on the Button (Click).
  • Once the button will click by the user, then all the ID details will display in the Data table control as like the below screenshot.
  • In the data table, you can see the specific user ID’s information like Given Name, Surname, Mail, and Job Title etc. Not only these fields, but also you can add more fields to the data table that you want to view on it.
PowerApps search active directory
PowerApps search active directory
  • To achieve this, set the below code on the Button’s OnSelect property as:
OnSelect = ClearCollect(
    AzureUserDetail,
    AzureAD.GetUser(TextInput1.Text)
)

Where,

  1. AzureUserDetail = Provide the collection name. To know more details about the PowerApps colection, refer to this link: Create Collection from SharePoint List in PowerApps
  2. TextInput1 = Text input control name where you will search the user ID

Before applying the formula, you need to ensure to add the Azure AD connector to the app. Otherwise, you may get errors in the formula.

Power Apps search active directory
  • Next, select the Data table control and set the Items property to the collection name i.e.
Items = AzureUserDetail
powerapps query active directory
PowerApps query active directory
  • Now save and preview the app. Enter the User AD ID and click on the button. When you will click on it, you can see all the details as shown above.

If you want to learn more details about Azure AD in PowerApps, then check out this complete tutorial: PowerApps get azure ad user

This is how to work with PowerApps search active directory.

In this topic, we will see how to work with PowerApps Search Email.

  • In the below scenario, I have two Text input boxes. In the first text box, when you will enter only the name of the user (O365User), then the Email Address of that specific person will appear in the another textbox.
  • PowerApps SearchUser function can return multiple results depending on the search term that you provide. That’s the reason behind the ‘incompatible table values’ error.
  • As in the first text box, I did not enter anything, that’s why the other text box appeared with the email address of the first user i.e. present in Office 365 users.
  • And, then I entered Bijay, and the other text box displayed with the Email address of the Bijay only.
Power Apps Search Email
Power Apps Search Email
  • To display the first result, you can apply the below formula on the result text box’s Default property as:
Default = First(Office365Users.SearchUser({searchTerm: txtEnterUser.Text})).Mail

Where,

  1. First = PowerApps First function always returns the first record of a table
  2. txtEnterUser = Specify the text input control name where you will enter the name of the user
  3. Mail = As I want the Email address of the specific user, so I have specified the parameter with .Mail
Search Email in PowerApps
Search Email in PowerApps
  • Similarly, if you want to display a comma (,) separated list of email addresses, then in that case, you can use the Concat function on the text input’s Defult property as:
Default = Concat(
    Office365Users.SearchUser({searchTerm: txtEnterUser.Text}),
    Mail & ", "
)

Refer to the below screenshot. Here, I have selected the Text input control’s Multiline mode property.

PowerApps Search Email
PowerApps Search Email

This is how to work with PowerApps Search Email.

Read: PowerApps Email Attachment Control – How to Use

Do you know what does the mean of PowerApps employee search? Read the complete PowerApps tutorial to learn what it is exactly: PowerApps Employee Directory

In PowerApps, do you want to search Office 365 users based upon their Job title? Yes, you can find the users very easily. Check out the below scenarios to know more details.

Example – 1:

  • When you do not enter any job title in the search box, then all the user names will appear in the gallery. If you will search for any job title, then the gallery will display with all the users who are specific searchable job-related as shown in the below screenshot.
PowerApps Search User by job title
PowerApps Search User by job title
  • To workaround with this, select the gallery and apply the below code on its Items property as:
Items = If(
    IsBlank(txtEnterJobTitle.Text),
    Office365Users.SearchUser(),
    Filter(
        Office365Users.SearchUser(),
        txtEnterJobTitle.Text = JobTitle
    )
)

Where,

  1. txtEnterJobTitle = Specify the text input control name where you can search the user’s job title
  2. JobTitle = As you want to filter the user gallery based upon their job title, so you need to specify the user parameter as JobTitle

NOTE:

To perform whatever things related to the Office 365, you must need to connect the Office365Users data source connector to the PowerApps. Otherwise some errors may occur while applying the code.
Power Apps Search User by job title
Power Apps Search User by job title
  • This above example explains how you can search the user by job title with a Text input control. Next we will see how to search and filter the user gallery without using any search text box.

Also, read: PowerApps send an email on submit

Example – 2: (PowerApps Search User JobTitle without using Text Box)

  • Here we will see how to search and filter the user gallery without using any search box control. That means, when you will apply the code, then the gallery will direct filter and display the appropriate result.
  • To achieve this, select the gallery and set its Items property to the below code as:
Items = Filter(
    Office365Users.SearchUser(),
    JobTitle = "Python Developer"
)

Where,

  1. JobTitle = As we want the user based upon their job title, so we need to specify this parameter
  2. Python Developer” = Mention the exact user’s job name/job title that you want to filter

Here, if you don’t pass any parameters to the SearchUser API, then it will only return 100 users.

Search User by job title in PowerApps
Search User by job title in Power Apps
  • In case you need more users, then you can pass the following formula to get 500 as a maximum.
Items = Filter(
    Office365Users.SearchUser(
        {
            searchTerm: "",
            top: 500
        }
    ),
    JobTitle = "Python Developer"
)
  • If you have more than 500 user or groups, then you would have to create multiple calls and write the answers to a collection.

This is how to work with PowerApps Search User by job title.

Read: PowerApps Filter SharePoint List (21 Examples)

Next, we will see how to search the user based upon their Phone number in PowerApps. Refer to the below example.

  • In the below image, you can see, when I entered the users mobile phone number, based upon that the gallery filtered and displayed the specific user details.
PowerApps Search Phone number
PowerApps Search Phone number
  • To achieve this, set the below formula on gallery’s Items propetry as:
Items = Search(
    Office365Users.SearchUserV2({top: 100}).value,
    txtEnterMobNo.Text,
    "mobilePhone"
)

Where,

txtEnterMobNo = Specify the text input control name where you can enter any user’s mobile number

Power Apps Search Phone number
Power Apps Search Phone number

This is how to use PowerApps Search Phone number.

To read more, refer to this link: PowerApps Validation: 9 Examples [Required Field, Email, Date, URL, Password, Number, ZIP]

In PowerApps, do you want to search the user by their display name? Yes, you can do this in many ways. Apart from that, you can also follow one of the below scenarios.

  • In the below screenshot, you can see there is a Text search box and a List box control in the app. The list box will appear with all the user full names while the search box is empty.
  • When you will search any user display name in the text box, then the list box will filter and appear with the specific user’s full name as shown below.
PowerApps Search User by Displayname
PowerApps Search User by Displayname
  • To get this thing, we can set the below code on the list box’s Items property as:
Items = Office365Users.SearchUser({searchTerm: txtTypeUser.Text})

Where,

txtTypeUser = Text input control name where you can enter the user display name

Power Apps Search User by Displayname
Power Apps Search User by Displayname

This explains how to work with PowerApps Search User by Displayname.

Also, you may like the below Power Apps guides:

In this PowerApps Tutorial, we discussed what does the mean of PowerApps Search user is and how you can get all the details about any user in PowerApps.

Also, we covered all the below topics:

  • PowerApps Search User
    • PowerApps Get Current User Information
    • PowerApps Get another User Information
  • PowerApps Search Office 365 users
  • PowerApps Search Person Field
  • PowerApps Search Active Directory
  • PowerApps Search Email
  • PowerApps Employee Search
  • PowerApps Search User by job title
  • PowerApps Search Phone number
  • PowerApps Search User by Displayname
>