web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Struggling to get user...
Power Apps
Answered

Struggling to get user image from a distinct list of users.

(0) ShareShare
ReportReport
Posted on by 174

Hi All,

 

bit of a niche one, but i'm struggling to get an image of a specific user that changes dynamically with time, as i only have the users full name as a "ThisItem.Result" tag. i've tried searching a user in another gallery and getting the profile, but i then can't return that to the same gallery as the one the result is found in. i've tried first, converting thisitem.result to text, and everything else i can think of. the database the name is pulled from does not have the users email so i'd need a dynamic way to search this.

 

thanks,

 

Alex. 

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Alex_Security 

    You could use the name and get the information from the Office 365 Users connector.

     

    However, is this SharePoint? If so, then you already have the information in the list if you are using a Person column.

    Also, what purpose does the Distinct play?  Keeping in mind that Distinct will only return a distinct table of a single column...sounds like you need more than just a single column.

     

    Please expand more based on the above.

  • Alex_Security Profile Picture
    174 on at

    Hi Randy,

     

    how would i use the name within the same gallery? i've tried using Office365Users.UserProfile(Office365Users.Search({searchterm:Thisitem.Name,top:1})).Mail but that doesn't work, i've removed the distinct, but even with the text name as a thisitem.text, i can't seem to get the user email as a label in the same gallery. my best guess is the below is due to the search returning a table as opposed to a text value?

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Alex_Security 

    Is this SharePoint?  Do you have a person column in use in your list?

     

    You are mention about getting the Mail of the user - but your original post was about the photo.  What is it that you are trying to achieve?

  • Alex_Security Profile Picture
    174 on at

    it's a sharepoint list, wherein the name column is a single line of text. not the best structure, but not one of my creation sadly. 

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Alex_Security 

    Okay, but are you trying to get a photo or an email?

  • Alex_Security Profile Picture
    174 on at

    so my thinking is, i need the email, from which to then get the photo. unless there is a route to directly get the photo using just the user name?

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Alex_Security 

    Yes, you will need more than the name - email is a logical place to start.

     

    This formula should provide your photo based on the name:

    With({_usr: First(Office365Users.SearchUserV2({searchTerm:ThisItem.Name, top:1}).value)},
     If(Office365Users.UserPhotoMetadata(_usr.UserPrincipalName).HasPhoto,
     Office365Users.UserPhotoV2(_usr.UserPrincipalName),
     SampleImage
     )
    )
  • Alex_Security Profile Picture
    174 on at

    Hi @RandyHayes ,

     

    so this code is working, but when the app loads in live i get the following error:

     

    Alex_Security_1-1648989367684.png

    I believe its because not all users have an image in AD, and i've even tried wrapping the whole with statement in an IFERROR(<formula>,"") but to no avail. is there any way of removing this error?

    thanks,

     

    Alex

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 393 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 278 Most Valuable Professional

Last 30 days Overall leaderboard