cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Siddz
Helper III
Helper III

UserPhotoMetadata Error

I have a canvas app with the SharePoint and the Office365Users connectors. I would like to display a user's Office 365 photo in a gallery if the user has a photo, or show a generic profile photo if they don't. The connected SharePoint list includes a person field, which is where the user photos are coming from. 

 

The gallery works as intended by displaying the user's photo if they have one and showing a generic profile image if they don't. However, I'm getting this error when I run the app:

Siddz_2-1642464369954.png

Here's what I have for the Image property on the photo in the gallery:

If(Office365Users.UserPhotoMetadata(ThisItem.SP_Person.Email).HasPhoto = true, Office365Users.UserPhotoV2(ThisItem.SP_Person.Email), 'No-Profile-Photo')

Here's the warning from Power Apps on the formula for the Image property: "This formula uses scope..."

Siddz_1-1642463397002.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Toby124
Frequent Visitor

@Siddz , can you try the expression? 

 

Expression: If(!IsBlank(ThisItem.Email),If(Office365Users.UserPhotoMetadata(ThisItem.Email).HasPhoto=true,Office365Users.UserPhotoV2(ThisItem.Email),SampleImage))

View solution in original post

2 REPLIES 2
Toby124
Frequent Visitor

@Siddz , can you try the expression? 

 

Expression: If(!IsBlank(ThisItem.Email),If(Office365Users.UserPhotoMetadata(ThisItem.Email).HasPhoto=true,Office365Users.UserPhotoV2(ThisItem.Email),SampleImage))

Hi, @Toby124.

 

Thanks! That seems to work. I updated the Image property on the photo in the gallery to this:

 

If(!IsBlank(ThisItem.SP_Person_Column.Email),If(Office365Users.UserPhotoMetadata(ThisItem.SP_Person_Column.Email).HasPhoto=true,Office365Users.UserPhotoV2(ThisItem.SP_Person_Column.Email),SampleImage))

 

Thanks again.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,260)