In this article, we are going to discuss the approach to get user profile in Microsoft Power Automate using default action “Get user profile (V2)” from the “Office 365 Users” connector. This action allows you to retrieve user profile information in a JSON object for the specified user.
To use this action, you will need to provide the User Principal Name (UPN) or email address of the user whose profile you want to retrieve. You will also need to specify which user profile properties you want 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 left navigation which will open the window with already existing flows with details information regarding them.
- Now select “New flow” dropdown which will bring all the possible flow list to create and let’s select “Instant cloud flow” for this demonstration.
- A new window will be opened with few actions to be taken as shown in the 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 selected for easier testing,
- Once you have provided the name and selected the trigger option, click on the “Create” button, as shown in position 3, to initially create the flow.
With “Get user profile”
action
- Click “New Step” button and select “Get user profile (V2)” action.
- After the action got added in the flow, you need to provide the user’s User Principal Name (UPN) in the parameter to get the user details as shown in the 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, there is an advanced feature named ‘Selected fields’ located in position 2.
- In the “Selected fields” section, you can specify the user properties that you want to retrieve exclusively, similar to the selected filter of an API call. Enter a comma-separated list of user properties that you want to retrieve (e.g. “DisplayName,Title,Department).
- For now, to test the action and check if the data is being retrieved or not, 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. All these properties can be accessed by dynamic properties as a feature of Power Automate. So we can use them as required easily.
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. All of 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, it is mandatory to provide the name which is usually a combination of the first name, middle initial, and last name. 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 time. |
||
User Type |
|
This property classifies user types, such as “Member” and “Guest”. |
||
|
String |
This property contains the SMTP address for the user, for example, demo@tahmidulabedin.me. |
||
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 domain must be present in the tenant’s collection of verified domains. This property is required when a user is created. The verified domains for the tenant can be accessed from the verifiedDomains property of organization. |
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, we will discuss the process to retrieve user profiles using Graph API in Power Automate, in the next article.