PAWIT.PW

My dedicated space, focusing on Power Apps and other Power Platform stuff 😉

Power Apps | User().Email is NOT user email

Prologue

Every newcomer or even professional app maker may familiar with Power Apps’ User().Email function It’s very simple function that stands for the email of user who opened the app but there’s a catch!

What if I say User().Email function isn’t give you a user email !?


What is UPN

User Principal Name (UPN) is like human-friendly unique identifier of each user

However, when your IT department created your Microsoft 365 account, The UPN and email are the same value by default, but it can be changed by your IT.

There are no problem to let them the same value for small-mid size business

but for large organization (1-10k+ users) To avoid problem like duplicate name and to let everyone have same UPN pattern, Many times UPN is configured to be [email protected]

  • UPN can be the same or differ from email address
  • UPN can be used as login credentials when user logging into Microsoft 365, email address can’t.
  • When sending email, the recipient will see email address as sender, not UPN

Problem with Power Apps

How this become a problem for Power Apps?

Well. I see many app maker use this function when they want to filter SharePoint list data

Filter(MyList, Person.Email = User().Email)

This code work fine if user’s UPN and email address are the same. but it won’ work when they are different because

  • Power Apps’ User().Email is giving us user UPN
  • SharePoint’s Person.Email is giving us user email address

As you can see that they are completely different values. So when you trying to filter based on this formula, you will not getting any result.


How to obtain actual user’s email

Good news is we can fix this by using Office 365 Users connector

By using this connector, It allow you to obtain almost every property of user’s profile. We can obtain user’s email address using this function

Office365Users.MyProfileV2().mail

So, now we can filter SharePoint person column using this function

Or you use this function to obtain email address of any users in organization using their UPN

Office365Users.UserProfileV2("[email protected]").mail
,

Leave a Reply

Your email address will not be published. Required fields are marked *