cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Power Apps
Power Apps

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

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
Highlighted
Power Apps
Power Apps

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

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

Highlighted
Frequent Visitor

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

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))

Highlighted
Advocate II
Advocate II

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

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))
Highlighted
Anonymous
Not applicable

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

Hello,

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

 

Highlighted
Post Patron
Post Patron

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

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
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (4,415)