Office 365 Users connector

In this exercise, we will learn about Office365Users connector and its various functions.

The Office 365 Users lets us access user profiles in your organization using our Office 365 account. We can perform various actions such as get our profile, another user's profile, a user's manager or direct reports.

Add the Office 365 Users Connect to the App
Step 1: Add a data connection and select Office 365 Users.

Step 2: Select Connect, and if prompted to sign in, enter your work account.
The Office 365 Users connection has been created and added to the app. Now, it's ready to be used.

1. Create a People Picker Control in Power Apps using Office 365 Users connection
We can create people picker control in the Powerapps by using the Office 365 Users connection. We can use the following powerapps formula to search the users in the organization.

Power Apps Formula

Office365Users.SearchUser({searchTerm: Text, top: Number})

The SearchUser function is used to search results of user profiles. If the SearchTerm, Text is “”, all the records are returned or only the top count specified.

Step 1: Click on + Insert and add a Combo box control.
Step 2: Add the following powerapps formula on the Items property of the Combo box control.

Power Apps Formula

Office365Users.SearchUser({searchTerm:MyCombobox.SearchText,top:10})

The above formula is a function call to the SearchUser function of the Office365Users connector in Power Apps. This function is used to search for users in the Office 365 environment based on the provided search criteria.

Here, MyCombobox is the name of our Combo box control. The top is a parameter in the function which specifies how many records are returned.

Office 365 Users connector

Step 3: Click on the Edit in the front of the Fields.

Office 365 Users connector

Step 4: Select the Person column from the Layout.

Office 365 Users connector

Step 5: Select the DisplayName as the Primary text, Mail as the Secondary text, and for the SearchField select Mail.

Office 365 Users connector

After the mapping, the image is shown like below.

Office 365 Users connector

Now if we preview the app, and click on the combo box it will be shown like the following image, where some Users records are fetched from the organization and shown here, above is the DisplayName and below its Mail, also if we search any specified user we are going to search by its Mail, not by its DisplayName, because we have selected SearchField Mail, we can change it according to the requirements.

Office 365 Users connector

Step 6: Let’s try to put some text in the combo box, the records are filtered.

Office 365 Users connector

Step 7: We can also filter the records returned by this function by using the Filter function of Powerapps.

Power Apps Formula

Office365Users.SearchUser({searchTerm:MyCombobox.SearchText,top:10})

For example, we are trying to filter it by the country name. So all the records that are returned by the function are further filtered by using the Filter function.

Power Apps Formula

Filter(Office365Users.SearchUser({searchTerm:MyCombobox.SearchText,top:10}), Country="India")

2. UserProfile
The UserProfile is a function used to retrieves a specific user profile.

Power Apps Formula

Office365Users.UserProfile("UserEmail”)

The above formula returns the record of the User profile of the user whose email id is passed as an argument.

Step 1: Add a Text label control and set its Text property to the following power apps formula.

Power Apps Formula

Office365Users.UserProfile("ashish@ashishg.onmicrosoft.com").DisplayName
Office 365 Users connector

We can see that the record is returned and by using the dot notation we are extracting the property from the record.

Office 365 Users connector

3. UserPhoto

The UserPhoto function is used to retrieve the user photo of any user, specified as an argument.

Power Apps Formula

Office365Users.UserPhoto("Email”)

Add a user profile photo
Step 1: Click on the + Insert tab, select Media >Image.
Step 2: Set the Image property to the following powerapps formula.

Power Apps Formula

Office365Users.UserPhoto("ashish@ashishg.onmicrosoft.com")
Office 365 Users connector

4. MyProfile
The MyProfile function is used to retrieves the profile for the current user.

Power Apps Formula

Office365Users.MyProfile()

It returns a record of the current user.

Office 365 Users connector

Step 1: Click on the + Insert menu, select Text label to add a label control to the screen.
Step 2: Set its Text property to the following powerapps formula.

Power Apps Formula

Office365Users.MyProfile().DisplayName
Office 365 Users connector

The label shows the information that you entered about the current user.

5. DirectReports The DirectReports function is used to get the direct reports of the specified user given as an argument.

Power Apps Formula

Office365Users.DirectReports(“Email”)

The function returns a table of records, who are the direct reporting to the specified user.

In the image below, we can see that Ashish Goel and Krishan is direct reporting to the Vinod Verma.

Office 365 Users connector

Step 1: Click on + Insert menu and select Vertical Gallery.
Step 2: Set its Items property to the following powerapps formula.

Power Apps Formula

Office365Users.DirectReports("vinod@ashishg.onmicrosoft.com")
Office 365 Users connector

The gallery shows information about the direct reports of the user you entered.

Office 365 Users connector

6. Manager
The Manager function is used to retrieves user profile for the manager of the specified user.

Power Apps Formula

Office365Users.Manager("Email")
Office 365 Users connector

Add a Text label control and set its Text property to the following powerapps formula.

Power Apps Formula

Office365Users.Manager("ashish@ashishg.onmicrosoft.com").DisplayName

The Office365Users.Manager("ashish@ashishg.onmicrosoft.com") returns the record of the manager of the specified user and by using the dot notation we are extracting the DisplayName property from that record.

Office 365 Users connector