cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
FAIZ_ext
Helper I
Helper I

user photo warning

Hello family,

I have created an application with profile pictures and here is the formula  : 

 

If(IsBlank('Utilisateursd’Office365'.UserPhoto('Utilisateursd’Office365'.UserProfile(ThisItem.User).Id));
SampleImage;
'Utilisateursd’Office365'.UserPhoto('Utilisateursd’Office365'.UserProfile(ThisItem.User).Id))

 when I share the application and when I navigate in the application I always get the following warning message : 

FAIZ_ext_0-1651742936737.png

 


how to solve this please

1 ACCEPTED SOLUTION

Accepted Solutions
JimmyWork
Memorable Member
Memorable Member

https://powerusers.microsoft.com/t5/Building-Power-Apps/UserPhotoMetaData-When-user-leaves-the-compa...

 

Suppress error message.

 

If(
!IsBlank(ThisItem.'Requested By'.Email),
If(
IfError(Office365Users.UserPhotoMetadata(ThisItem.'Requested By'.Email).HasPhoto, ""),
IfError(Office365Users.UserPhotoV2(ThisItem.'Requested By'.Email), ""),
SampleImage
),
SampleImage
)

View solution in original post

10 REPLIES 10
Nogueira1306
Super User
Super User

If(IsBlank('Utilisateursd’Office365'.UserPhoto(User().Email));
SampleImage;
'Utilisateursd’Office365'.UserPhoto(User().Email)

Try it like that

RusselThomas
Microsoft
Microsoft

Hi  @FAIZ_ext,

I'm guessing this is failing because the userID is empty or doesn't exist, not because there isn't a photo to display.  You can check and test for both using the userProfile and UserPhotoMetadata methods.

 

Perhaps add a label somewhere in the row that resolves the user id so you can see what it looks like;

 

 

'Utilisateursd’Office365'.UserProfile(ThisItem.User).Id

 

 

Either way, try testing the userID before calling the O365 users method to make sure it exists, then check for the photo, then render;

eg:

 

 

If(
    !IsBlank('Utilisateursd’Office365'.UserProfile(ThisItem.User).Id); //make sure user exists
    If(
        'Utilisateursd’Office365'.UserPhotoMetadata(ThisItem.User).HasPhoto = true;
        'Utilisateursd’Office365'.UserPhotoV2(ThisItem.User);
        SampleImage
    )
)

 

 

By the way, if you're using ThisItem.User as UserId input into 'Utilisateursd’Office365', you don't then have to go and fetch the Id to use as input into 'Utilisateursd’Office365'.  You just check the Id in the beginning to make sure the user exists.

Generally these days just making sure the user id exists is enough and you can still show user records that have no image without getting an error, so you can also try;

 

If(
    !IsBlank('Utilisateursd’Office365'.UserProfile(ThisItem.User).Id);
    Office365Users.UserPhotoV2(ThisItem.User);
    SampleImage
)

 

but if you're picking up errors with users that have no photo then try the UserPhotoMetadata() check as well.

Let me know how it goes.

 

Kind regards,

RT

@RusselThomas 

Hello ;

Thanks for your feedback and your formula
even with the formula I always detect error /wirning with users who do not have photo at the time I share the application and navigation

how can I check UserPhotoMetadata(). you mean exactly?

Thanks again

 

RusselThomas
Microsoft
Microsoft

Hi @FAIZ_ext ,

'Utilisateursd’Office365'.UserPhotoMetadata(ThisItem.User).HasPhoto = true;

This method should pull a record containing information about the user photo, whether or not they have a photo, without errors.  The record contains a field called HasPhoto which is true or false. 

 

If you call this, it should tell you whether there is a photo or not before you try calling UserPhotoV2().

It's supposed to avoid errors when there is a user record but no associated photo to render.

If you call this by itself and get an error, then you need to check your userId.

 

Can you share some more about the controls you're using or some screenshots?

Are you using a Gallery, or a form or just controls on a page?

 

Kind regards,

RT

hi @RusselThomas ; 

FAIZ_ext_0-1651759192898.png

There is a similar thread which resolved the error by putting a if condition around the ID and then referring to the same ID in office365 connector.
 

but I don't know how I can adapt it to my situation thank you very much




RusselThomas
Microsoft
Microsoft

Hi @FAIZ_ext ,

I don't see an error on your screenshot?  Is it still not working?

Kind regards,

RT

JimmyWork
Memorable Member
Memorable Member

https://powerusers.microsoft.com/t5/Building-Power-Apps/UserPhotoMetaData-When-user-leaves-the-compa...

 

Suppress error message.

 

If(
!IsBlank(ThisItem.'Requested By'.Email),
If(
IfError(Office365Users.UserPhotoMetadata(ThisItem.'Requested By'.Email).HasPhoto, ""),
IfError(Office365Users.UserPhotoV2(ThisItem.'Requested By'.Email), ""),
SampleImage
),
SampleImage
)

@JimmyWork  
THANK YOU SO SO SO SO  MUCH YOU saved my life

hi  @RusselThomas  

thank you for your efforts to help, i tried the solution of  @JimmyWork  and it works now

thank you again 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

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.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (1,023)