cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Matt_Froud
Frequent Visitor

How do I get User pictures to display using Office365Users connection?

I am a newbie to PowerApps, but have created a basic app connecting to a SharePoint Online data source.   

 

The datasource has a SharePoint list with a Poeple picker field in it. 

I have embedded a gallery on a form to show the User's Picture from the Office365Users Connector.

The code I am using is If(Office365Users.UserPhotoMetadata(ThisItem.Email).HasPhoto=false,SampleImage,Office365Users.UserPhoto(ThisItem.Email))

 

I am unable to see any User's Pictures ?   

I have also tried the UserPhotov2 property to no avail...

 

HasPhoto property seems to result to "False", but all the users concerned have photos in AAD / Office 365, even my own profile which the connector is using?

 

The Email addresses are correct and are identical to their UserPrincipalName attribute...

 

Please can you help me find the missing piece of the puzzle?  I guess there is something obvious I have missed?

 

Many thanks,

Matt

9 REPLIES 9
Pstork1
Dual Super User
Dual Super User

This is the formula that works for me

If(Office365Users.UserPhotoMetadata(ThisItem.UserPrincipalName).HasPhoto,Office365Users.UserPhotoV2(ThisItem.UserPrincipalName),SampleImage)

Its essentially the same as yours, but I made sure to use UPN not email.  You may have users that don't have emails in their profile.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Thanks for the info...

 

I am using a SharePoint Online List as the source of date, with a people picker field in it, so don't have the UserPrincipalName attribute to hand, only the Email attribute.  Although I have tried using Office365Users.SearchUser to get the UPN from the email and then use the UPN for the id for the UserPhoto / UserPhotoV2 calls, but still no joy.   

I have even tried hardcoding a UPN, but same result...

The wierd thing is I get no errors, just a blank picture, so looks like it is finding something, but picture just won't display?   
I have also output the result to a text field and get a link such as "appres://blobmanager/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/xx", so the code seems to be working?

We are in a Hybrid environment with 365, so have Azure AD Sync / ADFS with on-premise AD as the source.
Could it be related to this?

If you are in a hybrid environment then double check with your domain admins to make sure that user's email is equal to their UPN.  Usually it is, but its not guaranteed.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Matt_Froud
Frequent Visitor

Thanks, I know they are as I manage the AD myself...

Then I'm not sure why its not working for you.  As you can see from my example I'm using essentially the same formula you are and it works for me.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

I have spotted another similar case on the forums yesterday and they also have a hybrid O365 setup with Exchange On-Premise.   
I think this has something to do with it.   Not sure why, but I guess it is just not possible in this scenario ;-(   

I am going to put in a workaround and have a list of user's and images within the App to do a lookup on...

Thanks for all your help...

Matt

Hey @Matt_Froud 

 

Can you try to update your expression as:
 
If(!IsBlank(ThisItem.Email),If(Office365Users.UserPhotoMetadata(ThisItem.Email).HasPhoto,Office365Users.UserPhotoV2(ThisItem.Email),SampleImage),SampleImage)
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

If you are using Exchange On-premises then that is probably where the problem is coming from. User Profile pictures are synced from AD using Exchange on-line.  If you aren't using that then I expect something isn't registering correctly in terms of the pictures and that's why the HasPhoto in user metadata works for me but not for you.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

I agree.   Would just have been nice to have something from MS to state this is the case though.   Unable to find anything in their documentation suggesting this.   Can see the user's pictures in SharePoint Online, AzureAD and Office 365 portals fine  😉    Anyway, wasted enough time on this already, time for a custom workaround I think.   Thanks for your assistance and hope this post assists other people in the same situation...     

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,213)