Skip to main content

Notifications

Community site session details

Community site session details

Session Id : bKh//suo+diSMzikZ7Arru
Power Apps - Building Power Apps
Unanswered

Office365Users UserProfileV2 and UserPhotoV2 using alias

Like (0) ShareShare
ReportReport
Posted on 16 Apr 2020 15:48:56 by

I'm seeing some odd behavior when getting user details by Alias in Office365Users.

I'm at a large org and we tend to use alias in many systems as our identifier.

In this app we'd like to be able to type in an alias and pull back a user's information.

 

I've found that Alias works totally fine with UserPhotoV2 --  Office365Users.UserPhotoV2("alias@company.com") returns the profile photo.

 

However Office365Users.UserProfileV2("alias@company.com").DisplayName returns an error of "user not found"

 

What the story here -- why does one function allow me to use Alias as an ID, and another doesn't? Is this a bug?

Categories:
  • Jeremiah-GTH Profile Picture
    15 on 15 May 2024 at 01:37:10
    Re: Office365Users UserProfileV2 and UserPhotoV2 using alias

    Posted a solution in the wrong topic- had to many tabs open- ignore this please and my apology.

  • bjamal Profile Picture
    52 on 26 Oct 2022 at 12:19:31
    Re: Office365Users UserProfileV2 and UserPhotoV2 using alias

    HIi @RezaDorrani 

    I have a question. I am isung the same Expression und I am getting the result ( the id). 

    But I getting a notification that Userprofil() methode as incorrect paramater

    Office365Users.UserProfileV2(PrimEmailUser).id

    PrimEmailUser ist ThisItem.'Owning User'.'Primary Email'  ( I am using here a gallery and Source = Cases from CRM dynamics 365).

    I am gettign this error when I reload the cases via Revert function


  • RoseH Profile Picture
    2 on 12 May 2022 at 17:37:11
    Re: Office365Users UserProfileV2 and UserPhotoV2 using alias

    I'm 2 years late, but in case anybody else stumbles across this like I did...

     

    I had a similar problem. I had some users who are in the Office365Users collection and can be found using the Search function. But when I tried using their Mail property to get a photo (UserPhotoV2) or profile (UserProfileV2), it failed with the above error (bad id, reference properties missing, etc.).

     

    But... If I took the objects from the Search results and used the UserPrincipalName, not Mail, to pass to the UserPhotoV2 and UserProfileV2 functions on Office365Users, that worked.

  • Community Power Platform Member Profile Picture
    on 01 May 2020 at 18:01:08
    Re: Office365Users UserProfileV2 and UserPhotoV2 using alias

    Hi @v-bofeng-msft  -- alias is an alternate email address. "Alias" is a Microsoft/Outlook term, it's not ours!

    Again my confusion comes from being able to use Alias with UserPhotoV2, but alias failing to work with UserProfileV2.

     

    According to the documentation you shared, the two functions accept the exact same parameters, "User principal name or email ID"

     

    So it does not make sense that a user's alias works in one function but does not work in the other.

     

  • v-bofeng-msft Profile Picture
    on 20 Apr 2020 at 09:38:19
    Re: Office365Users UserProfileV2 and UserPhotoV2 using alias

    Hi @Anonymous :

    Thank you very much for exploring PowerApps and pointing out this problem.

    Have you solved your problem?

    According to the definition of this in the document, we should only use User principal name or email id to retrieve data. Could you tell me what is the alias?

    Get user photo (V2)

    Parameters

    Name

    Key

    Required

    Type

    Description

    User (UPN)

    id

    True

    string

    User principal name or email id

     

    Get user profile (V2) Parameters

    Name

    Key

    Required

    Type

    Description

    User (UPN)

    id

    True

    string

    User principal name or email id

    Select fields

    $select

     

    string

    Comma separated list of fields to select. Example: surname, department, jobTitle

    Best Regards,

    Bof

  • Community Power Platform Member Profile Picture
    on 17 Apr 2020 at 16:27:17
    Re: Office365Users UserProfileV2 and UserPhotoV2 using alias

    Hi @v-bofeng-msft 

     

    For these "Contacts" or "Guest Users," are you finding that UserPhotoV2 works fine with an alias, but only UserProfileV2 fails with an alias?

     

    Just to be 100% clear about the strange behavior I am seeing:

     

    Let's say I have some user John Doe, they have email John.Doe@business.com and an alias of JD123

    The end goal is to be able to enter JD123 into my PowerApp and return user details.

     

    I am finding that both functions (UserPhotoV2 and UserProfileV2) resolve correctly if I use John.Doe@business.com

     

    I am finding that UserPhotoV2 resolves correctly but UserProfileV2 fails to resolve if I use JD123@business.com , with error code "ResourceNotFound" and message "User Not Found"

     

    I am able to eventually get the user's profile by using SearchUsersV2 with searchterm JD123

     

    It is not clear to me why UserPhotoV2 can resolve my users by alias@business.com but UserProfileV2 cannot. This is occurring for every user I have tested in my organization.

  • v-bofeng-msft Profile Picture
    on 17 Apr 2020 at 05:13:43
    Re: Office365Users UserProfileV2 and UserPhotoV2 using alias

    Hi @Anonymous 

    The first thing I want to explain is that "DisplayName" is the wrong parameter name, and the correct parameter name is "displayName".(Although PowerApps may sometimes correct it automatically)

    I was also surprised to see this strange issue, so I spent some time doing the test.

    At first I thought it was a user's permission problem, when I use a test account that does not have access to the admin center to test, both formulas worked well.

    Finally, I tried to use the email addresses of different types of users as parameters, and the problem occurred:

    Active users: the formula works very well.

    Contacts: the formula “Office365Users.UserProfileV2” reports an error, the content is: "User Not Found".

    Guest users: the formula “Office365Users.UserProfileV2” reports an error, the content is: "Resource does not exist or one of its queried reference-property objects are not present".

    1.jpg

    At the moment I am not quite sure what is causing your problem, but I suggest that you can go to the admin of your organize and ask him what type of the user you are searching for.

    Best Regards,

    Bof

  • RezaDorrani Profile Picture
    12,141 on 17 Apr 2020 at 03:05:21
    Re: Office365Users UserProfileV2 and UserPhotoV2 using alias

    @Anonymous 

     

    Not sure if I understood the question

    But when I tried  Office365Users.UserProfileV2(User().Email).DisplayName  - Gave me a syntax error

    whereas  Office365Users.UserProfileV2(User().Email).displayName - works 

     

    --------------------------------------------------------------------------------
    If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 89 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 60

#3
stampcoin Profile Picture

stampcoin 48

Overall leaderboard
Loading started