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 :
how to solve this please
Solved! Go to Solution.
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
)
If(IsBlank('Utilisateursd’Office365'.UserPhoto(User().Email));
SampleImage;
'Utilisateursd’Office365'.UserPhoto(User().Email)
Try it like that
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
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
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 ;
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
)
thank you for your efforts to help, i tried the solution of @JimmyWork and it works now
thank you again
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
181 | |
52 | |
41 | |
40 | |
34 |
User | Count |
---|---|
262 | |
81 | |
71 | |
69 | |
66 |