cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kman42
Helper II
Helper II

Office365Users.UserPhoto not displaying photo

I am having a terrible time trying to get a photo to dispaly:

 

Office365Users.UserPhotoV2(ThisItem.email)

ThisItem.email resolves correctly to an email address. I have also tried by pulling the id directly from the connector:

Office365Users.UserPhotoV2(Office365Users.MyProfileV2().id)

And I've tried manually entering the email address:

Office365Users.UserPhotoV2("myemail.company.org")

The image is just blank. I updated my profile picture this morning (I didn't have one previously). It shows up in the top right of the PowerApps design page, but isn't showing up in the top right of office.com. It does show up when I look at my profile settings in office.com (wierd).

 

Maybe this is a problem with the profile picture and not my code?

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-monli-msft
Community Support
Community Support

Hi @kman42 ,

 

Check on below blog:
http://toddbaginski.com/blog/how-to-display-office-365-user-profile-images-in-powerapps/

 

I just tested with the formula included and it works for me.

If(
    IsBlank(ThisItem.Id),
    'profilepic-generic-user',
    If(
       Not(UserDomain.Text = MyDomain),
       'profilepic-generic-user',
       (
        If(
            Office365Users.UserPhotoMetadata(ThisItem.Id).HasPhoto = true,
            Office365Users.UserPhoto(ThisItem.Id),
            'profilepic-generic-user')
           )
       )
   )

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Pstork1
Dual Super User
Dual Super User

Try a different user's email to see if you can retrieve their photo.  I've used that connector to get photos for display in the past with no issues. But it can take a significant amount of time before your profile photo gets updated.  I would suspect that's the problem and not your code.



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

Join me at 365 and PWR EduCon in Chicago
EduCon Chicago 2022

K-A-R-L
Solution Specialist
Solution Specialist

Hi @kman42 ,

You can try using the Set() function and the email address as global variable.
 

On the OnStart:
 Set(MyProfile,Office365Users.MyProfile());

It may take some time to profile pic to sync. Deleting your cache and using another browser might work.

Cheers

v-monli-msft
Community Support
Community Support

Hi @kman42 ,

 

Check on below blog:
http://toddbaginski.com/blog/how-to-display-office-365-user-profile-images-in-powerapps/

 

I just tested with the formula included and it works for me.

If(
    IsBlank(ThisItem.Id),
    'profilepic-generic-user',
    If(
       Not(UserDomain.Text = MyDomain),
       'profilepic-generic-user',
       (
        If(
            Office365Users.UserPhotoMetadata(ThisItem.Id).HasPhoto = true,
            Office365Users.UserPhoto(ThisItem.Id),
            'profilepic-generic-user')
           )
       )
   )

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
suariokbea
Frequent Visitor

For the ones that still can't make this work I found out a work around following the solution of this post.

In my case I was looking for a work around for iPad.

I found out that the profile image came from Sharepoint:

https://[yourcompanyname].sharepoint.com/_layouts/15/UserPhoto.aspx?Size=L&AccountName=  + [User Email]

But when you write this link on the image value , sometimes PowerApps dont pull the content of the image, it just "reads the link value", so it is not going to render in the canvas. So what I did was to make a PowerAutomate Flow to Pull the content  of that link:

Steps:

  • Make a Instant Clod Power Automate Flow triggered form PowerApps
  • Select the Send an HTTP request to SharePoint and configured it as follow (you need to send from powerapps the desired Email):
  • image.png
  • This is going to retrieve the type-content and content , you can filtered it by adding a Compose step and setting the value to 
  • image.png

  • outputs('Send_an_HTTP_request_to_SharePoint')?['body'].$content
  • Send back the content to Power Apps selecting the "Respond to a PowerApp or flow" connector
  • image.png
  • In power apps you just need to set in OnStart rule the next sentence  
  • Set(
    varContent;
    'NameOfYourFlow'.Run(User().Email).content
    );;
  • And due the content is in base64 format you need to set the value of the desired image as
  • "data:image/jpeg;base64," & varContent

Tada Magic! Hope It helps someone

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Solution Authors
Top Kudoed Authors
Users online (4,202)