cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JimmyWork
Memorable Member
Memorable Member

Display current user profile picture (On all devices)

Hi

 

I want to display the current logged in users profile image and i want it to work on mobile devices to.

Now if i use the following lines it works but multiple times i can see an error showing, the image is still displayed correctly, sometimes the error message is now showed at all and i don't know why i receive the error at all.

 

If(Microsoft365Users.UserPhotoMetadata(Microsoft365Users.MyProfileV2().mail).HasPhoto=false,SampleImage,Microsoft365Users.UserPhotoV2(Microsoft365Users.MyProfileV2().mail))

 

Error Message displayed at random (Image is always showed correctly even if the error message is displayed)

2020-09-02 18_53_59-Window.png

 

If i use User().Image it works on some devices but not all and not for all users.

Any suggestion how i can work around this? Or let me know whats wrong with my lines.

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @JimmyWork :

I've made a test but did not encounted the problem you mentioned.

Let us work together step by step to find the problem:

Firstly,I'm not sure if you quoted the name of the connector correctly.Could you show me a screenshot of your data source?

1.JPG

Secondly,I am not sure if this is caused by Throttling Limits.

The call limit for Office 365 Users connector is 1000 in 60s.Although this is unlikely, you can try this code to reduce the number of calls.

 

If(
    Office365Users.UserPhotoMetadata(User().Email).HasPhoto,
    Office365Users.UserPhotoV2(User().Email),
    SampleImage
)

 

On your side,it should be

 

If(
    Microsoft365Users.UserPhotoMetadata(User().Email).HasPhoto,
    Microsoft365Users.UserPhotoV2(User().Email),
    SampleImage
)

 

Finally,I think a safer way is to use the above code to get the user's picture and save it in a variable when loading the app. This prevents the app from calling office365User connection repeatedly.

1\Set the App's OnStart property to:

 

Set(
    UserPhoto, /*UserPhoto is my custom variable*/
    If(
        Office365Users.UserPhotoMetadata(User().Email).HasPhoto,
        Office365Users.UserPhotoV2(User().Email),
        SampleImage
    )
)

 

2\Set the image control's Image property to:

 

UserPhoto

 

Best Regards,

Bof

View solution in original post

2 REPLIES 2
v-bofeng-msft
Community Support
Community Support

Hi @JimmyWork :

I've made a test but did not encounted the problem you mentioned.

Let us work together step by step to find the problem:

Firstly,I'm not sure if you quoted the name of the connector correctly.Could you show me a screenshot of your data source?

1.JPG

Secondly,I am not sure if this is caused by Throttling Limits.

The call limit for Office 365 Users connector is 1000 in 60s.Although this is unlikely, you can try this code to reduce the number of calls.

 

If(
    Office365Users.UserPhotoMetadata(User().Email).HasPhoto,
    Office365Users.UserPhotoV2(User().Email),
    SampleImage
)

 

On your side,it should be

 

If(
    Microsoft365Users.UserPhotoMetadata(User().Email).HasPhoto,
    Microsoft365Users.UserPhotoV2(User().Email),
    SampleImage
)

 

Finally,I think a safer way is to use the above code to get the user's picture and save it in a variable when loading the app. This prevents the app from calling office365User connection repeatedly.

1\Set the App's OnStart property to:

 

Set(
    UserPhoto, /*UserPhoto is my custom variable*/
    If(
        Office365Users.UserPhotoMetadata(User().Email).HasPhoto,
        Office365Users.UserPhotoV2(User().Email),
        SampleImage
    )
)

 

2\Set the image control's Image property to:

 

UserPhoto

 

Best Regards,

Bof

@v-bofeng-msft Thank you, this seems to work not producing the error message. Really appreciate the help 🙂

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,328)