cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
thanke
Helper I
Helper I

How do I use the the Office365Users."UserPhoto" option and what is the syntax for this.

I am trying to pull in user photos from O365 into a PowerApp and noticed that if I connect to the Office365Users data connection there  is a "UserPhoto" option you can select from the drop down but I can't seem to figure out the needed syntax.

 

Thanks,

Todd

 

1 ACCEPTED SOLUTION

Accepted Solutions
CarlosFigueira
Power Apps
Power Apps

The UserPhoto function on the Office365Users connector needs the id of the user for which you want the picture. There are a few ways you can get that:

  • If you want your own picture, you can use the MyProfile() function: Office365Users.UserPhoto(Office365Users.MyProfile().Id)
  • If you want the pictures for someone else, you can use any of the functions that return the users. For example, you can use Office365Users.SearchUser({searchTerm:"John Doe"}), and that will return a table with all users that match that name. If you set that expression to a Gallery's Item property, then within the gallery template you can have an image control with its Image property set to Office365Users.UserPhoto(ThisItem.Id)

View solution in original post

5 REPLIES 5
CarlosFigueira
Power Apps
Power Apps

The UserPhoto function on the Office365Users connector needs the id of the user for which you want the picture. There are a few ways you can get that:

  • If you want your own picture, you can use the MyProfile() function: Office365Users.UserPhoto(Office365Users.MyProfile().Id)
  • If you want the pictures for someone else, you can use any of the functions that return the users. For example, you can use Office365Users.SearchUser({searchTerm:"John Doe"}), and that will return a table with all users that match that name. If you set that expression to a Gallery's Item property, then within the gallery template you can have an image control with its Image property set to Office365Users.UserPhoto(ThisItem.Id)

View solution in original post

I have tried this solution with Office365Users.UserPhoto(ThisItem.Id) but I get the following error The server returned with a HTTP error code 404. All the other Information is showing correctly though, just not the picture.

 

**Edit: I Believe this error shows for users that dont have a image selected. It appears to be working for users that have chosen an image. A decent work around is:

 If(Office365Users.UserPhotoMetadata(ThisItem.Id).HasPhoto=false,SampleImage,Office365Users.UserPhoto(ThisItem.Id))

I have the same problem but the solution does not seems to be working. 

 

below is the formula I am using. 

 

If(Office365Users.UserPhotoMetadata(Office365Users.MyProfile().Id).HasPhoto=false,SampleImage, Office365Users.UserPhoto(Office365Users.MyProfile().Id))
Anonymous
Not applicable

Hello,

I got the same error,but don't know where to change the funtion.

 

If this code doesn't detect a user without a profile image, then what is the solution because I'd like to insert a generic user image missing.  Any recommendations are greatly appreciated.

If(Office365Users.UserPhotoMetadata(Office365Users.MyProfile().Id).HasPhoto=false,SampleImage, Office365Users.UserPhoto(Office365Users.MyProfile().Id))

 

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,523)