web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Conditionally displayi...
Power Apps
Unanswered

Conditionally displaying user images

(0) ShareShare
ReportReport
Posted on by 67

I have an office status app that shows team members that are out of the office on a certain date or range of dates.  If team members are out of the office, their name and their Office365Users image displays in a gallery.  Some members don't have an image, so I'm conditionally displaying a generic icon in that case.  My issue though is if no team members are out on a given day, an error is thrown for passing an invalid parameter (blank) to the Office365Users function.  It all seems to work fine when natively running the app, but when viewed in Teams the error messages are displayed at the top.

 

I've tried adding a condition to check if the gallery is empty first, but it doesn't seem to work.  Here's my setup.

 

User image Image property:

If(
!IsEmpty('OOO Gallery'),
If(
Office365Users.UserPhotoMetadata(ThisItem.'Team Member'.Email).HasPhoto = true,
Office365Users.UserPhotoV2(ThisItem.'Team Member'.Email)
)
)



User image Visible property:

!IsEmpty('OOO Gallery')

 

Icon Visible property:

If(
!IsEmpty('OOO Gallery'),
If(
Office365Users.UserPhotoMetadata(ThisItem.'Team Member'.Email).HasPhoto = false,
true,
false
)
)

 

Any help on what I'm doing wrong would be appreciated.

Categories:
I have the same question (0)
  • victorcp Profile Picture
    2,350 Moderator on at

    Hi
    I already faced the same issue and this is how I handled:

    • Enable the 'Formula-level error management' under settings>upcoming features>Formula-level error management (you have to restart the app)
      victorcp_0-1676993867753.png
    • Now go back to your image properties and set it like this:

     

    IfError(
     Office365Users.UserPhotoV2(ThisItem.'Team Member'.Email),
     SampleImage // Image when there is no photo or it is an error
    )

     

    and that's it, I hope it helps 🙂

     

  • birgem11 Profile Picture
    67 on at

    Thanks @victorcp , but it seems my issue isn't whether or not the user has an Office365 user photo, but rather the error is thrown when there isn't an item in my gallery.  The image property is still trying to pass an email to the UserPhotoV2 parameter and throwing an error because there isn't one to pass.  It seems to be ignoring my !IsEmpty condition.

     

    I tried your function above and pulls in the user photo fine if they have one, but doesn't seem to show my sample image if they don't (with my existing icon visibility property turned off).

  • victorcp Profile Picture
    2,350 Moderator on at

    Can you share the error?

  • birgem11 Profile Picture
    67 on at

    Office365Users.UserPhotoMetadata failed: The method 'UserPhotoMetadata' has an invalid value for parameter 'userId'

  • victorcp Profile Picture
    2,350 Moderator on at

    The error is on the icon property I forgot about it hahah

     

    try this:

     

    On the image:

    • image property:

     

    IfError(
     Office365Users.UserPhotoV2(ThisItem.'Team Member'.Email),
     Blank()
    )

     

    • visible property:

     

    !IsBlank(Self.Image)

     

     

    On the icon set the visible like this

     

    !Image.Visible // use the name of your image component

     

     This way the performance will be better

  • birgem11 Profile Picture
    67 on at

    Thanks @victorcp , everything seemed to work except the icon doesn't display.  The Visible property resolves to true, even though the item in the gallery doesn't display a team member pic.

    birgem11_0-1677014593504.png

     

  • victorcp Profile Picture
    2,350 Moderator on at

    if you select the whole code you will see it will be false, the exclamation deny the true

    victorcp_0-1677050788699.png

     

    victorcp_1-1677050899998.png

    victorcp_2-1677050913989.png

     

  • birgem11 Profile Picture
    67 on at

    OK, that makes sense.  However these still don't seem to be resolving correctly when a user does not have an image, as you can see below:

    User image Image property:

    birgem11_0-1677078827259.png

    User image Visible property:

    birgem11_1-1677078888530.png

    Icon Visible property:

    birgem11_2-1677078924200.png

     

     

    Users with images display fine, but users without images don't show anything.

  • victorcp Profile Picture
    2,350 Moderator on at

    I've made a quick test, and it worked perfectly on my side:

    victorcp_0-1677142124088.pngvictorcp_1-1677142134611.png

     

    question: is 'Team Member' a person/group field?

     

  • birgem11 Profile Picture
    67 on at

    re: question: is 'Team Member' a person/group field? - Yes, it is.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard