Get User Properties With “Get User Profile” Action In Power Automate

Introduction

In this article, we are going to discuss the approach to get a user profile in Microsoft Power Automate using the default action "Get user profile (V2)" from the "Office 365 Users" connector. This action lets you retrieve the specified user's user profile information in a JSON object.

To use this action, you must provide the User Principal Name (UPN) or email address of the user whose profile you want to retrieve. You must also specify which user profile properties you wish to retrieve by providing a comma-separated list of property names. You can then use this information in subsequent actions or steps in your flow.

Here are the steps to get user properties using the "Get user profile (V2)" action,

Create a New Flow

  • To start with, go to this link.
  • Sign in to the Power Automate portal with proper authentication and select an environment where you want to build the flow. To create an environment, you can follow this article.
  • Now click "My flows" from the left navigation, which will open the window with existing flows and details about them.
  • Now select the "New flow" dropdown, which will bring all the possible flow lists to create and let's select "Instant cloud flow" for this demonstration.

Figure 1: Power Automate window for new flow

Figure 1- Power Automate window for a new flow

  • A new window will be opened with a few actions to be taken, as shown in Figure 2.
  • Need to provide a name for the flow in position 1, as here I have used "GetUserProfileDetails" in this example.
  • Now to choose the trigger of this flow from position 2, you can select according to your requirements. For instance, in this example, "Manually trigger a flow" has been chosen for easier testing,
  • Once you have provided the name and selected the trigger option, click the "Create" button, as shown in position 3, to create the flow.

Figure 2: Creating Instant cloud flow

Figure 2- Creating Instant cloud flow

With the "Get user profile" action

  • Click the "New Step" button and select the "Get user profile (V2)" action.
  • After the action is added to the flow, you must provide the user's User Principal Name (UPN) in the parameter to get the user details, as shown in Figure 3, position 1. The User Principal Name (UPN) is an internet-style login name that follows the RFC 822 standard and usually corresponds to a user's email address. It consists of an alias and a domain, which must be verified and present in the tenant's collection of domains.
  • Providing the accurate UNP is sufficient to retrieve user details with this default action. However, an advanced feature named 'Selected fields' is located in position 2.
  • In the "Selected fields" section, you can specify the user properties you want to retrieve exclusively, similar to the selected filter of an API call. Enter a comma-separated list of user properties you want to retrieve (e.g. "DisplayName, Title, Department).

Figure 3: Adding Get user profile (v2) action

Figure 3- Adding Get user profile (v2) action

  • To test the action and check whether the data is being retrieved, we can provide a static User Profile Name in the 'User (UPN)' field and run the flow.
  • After successfully running the flow, the properties will be displayed, as shown in Figure 4. All the properties that can be retrieved are listed and discussed in the 'User Profile Properties' section. Dynamic properties can access all these properties as a feature of Power Automate. So we can use them as required quickly.

Figure 4: Retrieved data with Get user profile action

Figure 4- Retrieved data with Get user profile action

User Profile Properties

Here are a few examples of user properties that can be retrieved using the "Get user profile" action, along with the property type and details. These properties can be added as dynamic content to the next step in the flow.

Property Type Description
Display Name String To create a user, providing the name, usually a combination of the first, middle, initial, and last names, is mandatory. This property cannot be cleared during updates, and its maximum length is restricted to 256 characters.
Given Name String This property represents the user's first name, and its length cannot exceed 64 characters.
Surname String This property represents the user's last name, with a maximum length of 64 characters.
Nickname String The mail alias for the user. This property must be specified when a user is created. Maximum length is 64 characters.
Birthday DateTimeOffset The date of birth of the user.
Business Phones String collection This property is a collection of strings that holds the user's phone numbers, but it only allows setting one number.
Hire Date DateTimeOffset The user's hire date is always expressed in UTC.
User Type String This property classifies user types, such as "Member" and "Guest".
Mail String This property contains the SMTP address for the user, for example, [email protected].
User Principal Name String The user principal name (UPN) of the user. The UPN is an Internet-style login name for the user based on the Internet standard RFC 822. By convention, this should map to the user's email name. The general format is alias@domain, where the domain must be present in the tenant's verified domain collection. The verified domains for the tenant can be accessed from the verifiedDomains property of the organization. This property is required when a user is created.


Conclusion

In conclusion, the "Get user profile" action in Power Automate allows you to retrieve specific properties of a user's profile from a connected system. Once you've retrieved the user's profile, you can use the dynamic content feature in Power Automate to insert the retrieved properties into subsequent actions, such as customizing notifications, assigning tasks, or tracking activities within a workflow or business process.

This action provides you with specific information about a user that can be used to streamline processes and improve efficiency within your organization.

Furthermore, the next article will discuss retrieving user profiles using Graph API in Power Automate.


Similar Articles