Forum Discussion
PowerApps Profile Pic IF statement
Hi All,
I've currently got a SP list with a people field showing the users profile picture. In PowerApps I've a gallery to display all my columns including the profile picture with the below code. (Picture= column for my picture)
Office365Users.UserPhoto(ThisItem.Picture.Email)
This works perfectly fine apart from any users who don't have a profile picture set, I'd like to set an IF statement to display a specific picture i.e. SampleImage if the user doesn't have a picture.
I've checked many methods, scouring and searching and can't seem to get this to work, got to be really simple yet i think I've blinded myself with the attempts.
Any support on this would be great and appreciated.
Thanks
Cecil
Office365Users.UserPhotoMetadata().HasPhoto
will return true or false. You can use this in an If condition:
If( Office365Users.UserPhotoMetadata(Gallery1.Selected.Mail).HasPhoto, Office365Users.UserPhoto(Gallery1.Selected.Mail), 'robot-face' )
To use the sample image use:
If( Office365Users.UserPhotoMetadata(Gallery1.Selected.Mail).HasPhoto, Office365Users.UserPhoto(Gallery1.Selected.Mail), SampleImage )
Hope this helps.
Ellis
- ekarimBrass Contributor
Office365Users.UserPhotoMetadata().HasPhoto
will return true or false. You can use this in an If condition:
If( Office365Users.UserPhotoMetadata(Gallery1.Selected.Mail).HasPhoto, Office365Users.UserPhoto(Gallery1.Selected.Mail), 'robot-face' )
To use the sample image use:
If( Office365Users.UserPhotoMetadata(Gallery1.Selected.Mail).HasPhoto, Office365Users.UserPhoto(Gallery1.Selected.Mail), SampleImage )
Hope this helps.
Ellis
- PerfPCCopper Contributor
Just noticed when running the App I get the error in the attached image.
The exact code I used was derived from your information below, the image of the user and the default image shows fine but with the error. Any ideas what this could be or a possible fix.
If( Office365Users.UserPhotoMetadata(ThisItem.Picture.Email).HasPhoto, Office365Users.UserPhoto(ThisItem.Picture.Email), 'My-Default-Image' )
Many Thanks
Cecil