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 / Image error handling
Power Apps
Answered

Image error handling

(0) ShareShare
ReportReport
Posted on by 185

Hey all,

 

When my app starts I am getting an error:

 

Office365Users.UserPhoto failed: The function 'UserPhoto' has an invalid value for parameter 'userId' - a blank value was passed to it where it was not expected. Please make sure that a valid argument is passed to the function.

 

This is because I have an image placeholder but no user selected

 

If(
!IsBlank(Image2),
Office365Users.UserPhoto(userSelect.Selected.UserPrincipalName)
)

 

So I thought if no user is selected, then use a default image. I created a new Image called Image3 and gave it an image

 

da1vea_0-1707360050153.png

I have tried a few variations but not getting it to work

 

If(
 !IsBlank(Image2),
 Office365Users.UserPhoto(userSelect.Selected.UserPrincipalName),
 Image3
)

If(
 !IsBlank(Image2),
 Office365Users.UserPhoto(userSelect.Selected.UserPrincipalName),
 Image(Image3)
)

If(
 !IsBlank(Image2),
 Office365Users.UserPhoto(userSelect.Selected.UserPrincipalName),
 Image {
 Image: Image3
 }
)

 

Any idea how I can achieve this? The Image3 is just an idea, if there is a better way to stop getting this error then happy to look at that 🙂

 

Thanks

Categories:
I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    on at

    Hi @da1vea ,

     

    Please try this formula instead:

     

    If(
    !IsBlank(userSelect.Selected),
    Office365Users.UserPhoto(userSelect.Selected.UserPrincipalName)
    )

     

     

    Best Regards,

    Bof

  • da1vea Profile Picture
    185 on at

    Thanks @v-bofeng-msft ,

     

    Your expression was just missing the backup image. I set it to

     

    If(
    !IsBlank(userSelect.Selected),
    Office365Users.UserPhoto(userSelect.Selected.UserPrincipalName),
    SampleImage
    )

     

    And that is working as expected

     

    Thanks,
    David

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 765 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 272

Last 30 days Overall leaderboard