Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Suggested answer

Office365Users.UserPhotoMetadata failed when user account deleted

(1) ShareShare
ReportReport
Posted on by 75
In Power Apps, when retrieving a user's photo using the code below, there are no issues with existing users. However, if a user's account has been deleted, the FX Office365Users.PhotoMetadata function will return an error.
 
If(!IsBlank(ThisItem.员工邮箱),
If( Office365Users.UserPhotoMetadata(ThisItem.员工邮箱).HasPhoto=true,Office365Users.UserPhotoV2(ThisItem.员工邮箱),p),p)
 
Error message.
 
Office365Users.UserPhotoMetadata failed: {
"error": {
"code": "ErrorEntityNotFound",
"message": "Exception of type 'Microsoft.Fast.Profile.Core.Exception.EntityNotFoundFromCafeHintException' was thrown.",
"innerError": {
 
AI recommends using the FX below. However, this time, for users who have not set up a photo (their account exists), Power Apps displays an empty image. It should instead show the default photo labeled "P" as shown below. any alternative solution?
 
If(
    !IsBlank(ThisItem.员工邮箱),
    
    If(
       
        !IsBlank(
            Office365Users.UserPhotoV2(ThisItem.员工邮箱)
        ),
        Office365Users.UserPhotoV2(ThisItem.员工邮箱),
        p
    p 
)
 
 
 
  • WarrenBelz Profile Picture
    148,353 Most Valuable Professional on at
    Office365Users.UserPhotoMetadata failed when user account deleted
    Sorry, out of ideas.
  • Henryzhou Profile Picture
    75 on at
    Office365Users.UserPhotoMetadata failed when user account deleted
    @WarrenBelz Hi Warren, Thanks for your help.  it  still doesn't work. the user who no photo setup that still show empty. code as below.
    If(
       !IsBlank(ThisItem.员工邮箱),
       If(
          IsError(Office365Users.UserPhotoMetadata(ThisItem.员工邮箱)),
          p,
          If(
          Office365Users.UserPhotoMetadata(ThisItem.员工邮箱).HasPhoto,
          Office365Users.UserPhotoV2(ThisItem.员工邮箱),
          p)
       ),p
    )
  • Henryzhou Profile Picture
    75 on at
    Office365Users.UserPhotoMetadata failed when user account deleted
    @Warren, Hi Warren, it doesn't work. the user who no photo setup that still show empty. 
  • WarrenBelz Profile Picture
    148,353 Most Valuable Professional on at
    Office365Users.UserPhotoMetadata failed when user account deleted
    What about this one ?
    If(
       !IsBlank(ThisItem.员工邮箱),
       If(
          IsError(Office365Users.UserPhotoMetadata(ThisItem.员工邮箱),
          p,
          Office365Users.UserPhotoMetadata(ThisItem.员工邮箱).HasPhoto,
          Office365Users.UserPhotoV2(ThisItem.员工邮箱),
          p
       )
    )
    Unfortunately I cannot test any of this presently.
  • Henryzhou Profile Picture
    75 on at
    Office365Users.UserPhotoMetadata failed when user account deleted
     , Thank you for your assistance. To clarify, I mean that the user's Active Directory account has been deleted, not the list item. Therefore, when using Office365Users.UserPhotoMetadata to retrieve the user's photo, it will result in an error. The Person and Group type field still retains the user information, but Office365Users.UserPhotoMetadata will return an error message.
  • Henryzhou Profile Picture
    75 on at
    Office365Users.UserPhotoMetadata failed when user account deleted
    @WarrenBelz Hi Warren, Thanks for your help. your code doesn't work either. it show empty instead of default photo "P". 

  • WarrenBelz Profile Picture
    148,353 Most Valuable Professional on at
    Office365Users.UserPhotoMetadata failed when user account deleted
    Try this and see if it works
    If(
       !IsBlank(ThisItem.员工邮箱),
       If(
          IsBlankOrError(
             Office365Users.UserPhotoV2(ThisItem.员工邮箱)
          ),
          p,
          Office365Users.UserPhotoV2(ThisItem.员工邮箱)
       ),
       p
    )
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee
  • Suggested answer
    Gabriel G. Profile Picture
    677 on at
    Office365Users.UserPhotoMetadata failed when user account deleted
    Hi there,

    Deletion is a bit different from other events (Create, Update). On deletion, system only keep the entity reference on the process (id, name, delete from,...) You will have to move your operation before deletion process and keep your picture in your application cache. Otherwise, the only thing you can get is the name or id.

    Simple alternative is to create a confirmation message for the user and get picture and values you need at this moment and keep them in variables. If user confirm deletion, you use your variables values. Otherwise, you flush values or they simply gonna get crush by the next deletion.

    I hope it helps!
    ______________________________________________________________
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1