Hi @Anonymous,
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