One of the best things about having a centralized authentication system is that all the information is easily accessible everywhere in the company. If you use SharePoint, you see this all the time, in lists, permissions, and more. So it’s no surprise that Power Automate provides us a way to fetch a person’s information, like country, display name, city, and picture, to name a few. To do this you have the Get User Profile action. It’s quite powerful so let’s explore it a bit further.

Where to find it?

To find it, you can search for the “Get User Profile” action.

Alert:
Microsoft changed the way that Power Automate displays the steps. Now you have a huge list of actions that you can search. It’s arguable that this is simpler or not, but now I’ll only provide the search string you have to write to find the action.

Here’s what it looks like.

Usage

The action refers to the user’s UPN or “User Principal Name,” which refers to the person’s name plus some information to make it unique. This is defined by your administrator, and it’s quite complex, so that I won’t describe it here. If you’re curious, you can go to the Azure AD reference page that explains this in further detail. What I want to show you is the other option. The email. It’s one of the safest ways to access the person’s information because:

  1. There are no special characters (names can be tricky in this regard)
  2. An email has a defined structure, so it’s easier to validate.
  3. It can be obtained in a lot of other actions while the UPN is trickier.

So my main recommendation is to use email when possible.

When you use the action, it won’t try to autocomplete your results. This is because you can have an expression to calculate the email or clean it up from another step in the Flow. Regardless you’ll get something like this:

As you can see, there’s quite a lot of information that you can get from the action. I’m only showing you a subset above.

Limitations

You can only get information from the users in your tenant (this is not necessary for your whole organization since it may be split into several areas). Also, you can only see the “public” information or the information that your administrator allows everyone to see. You can find the same information in the person’s profile in teams or outlook.

Recommendations

Here are some things to keep in mind.

Don’t calculate the UPN.

The UPN has a formula but doesn’t try to calculate it. If there’s an action that returns it, use it as is to get the best results. If you try to generate yourself, you’ll get some headaches and failing Flows.

Don’t generate the email.

Same as above. Emails may be generated using a formula, but things change, and there are exceptions. For example, how many David Smiths do you think a large organization has? Or Manuel Gomes in Portugal, for that matter 😀. My point is to use the email that comes from another action and avoid as possible hard-code it yourself.

Fetch only the fields you need

Aside from the UPN, there’s also an option to select the fields. You can define what fields you want to get, and the action will only fetch those. You’ll get a boost in performance if you do this, so keep this in mind. There are a lot of fields, so here’s the full list.

Name it correctly

The name is super important in this case since we’re getting the information of someone, but we need to define why we’re getting that information. Always build the name so that other people can understand what you are using without opening the action and checking the details.

Always add a comment.

Adding a comment will also help to avoid mistakes. Indicate why you are using that name, for example, where and how. Again, it’s important to enable faster debugging when something goes wrong.

Always deal with errors.

Have your Flow fail graciously when the user doesn’t exist and notify someone that something failed. It’s horrible to have failing Flows in Power Automate since they may go unlooked for a while or generate even worse errors. I have a template, and a template that you can use that will help you make your Flow resistant to issues. You can check all details here.

Am I missing something? Leave a comment or interact on Twitter. Let’s work together to make this reference as complete as we can

Back to the Power Automate Action Reference.

Photo by Ayo Ogunseinde on Unsplash

Manuel Gomes

I'm a Project Manager with experience in large projects and companies. I've worked in the past for companies like Bayer, Sybase (now SAP) and I'm currently working for Pestana Hotel Group.

View all posts by Manuel Gomes →

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: