Announcements
Hi!
I'm building an app that takes rows from an Excel file depending on some filters. The rows in the Excel contain names that more or less matches the names in their respective Office 365 profiles. This info is displayed in a gallery, and I want to create a connection where each entry in the gallery with information from the Excel gets the profile picture from the username that matches the name in the Excel file, but I haven't been able to find any answer that works. My gallery has the following fields:
Thanks in advance!
Hi @JoelAle,
User profile photos can be obtained using the following code, where locEmployeeName is the employee name:
Office365Users.UserPhotoV2(First(Office365Users.SearchUserV2({searchTerm:locEmployeeName}).value).Id)
If I have answered your question, please mark your post as Solved.If you like my response, please give it a Thumbs Up.Follow me online.
Thanks! It works, kind of... I get error The method 'UserPhotoV2' has an invalid value for parameter 'id'. Can it be that some of the names don't match any profile? Or maybe that some of the accounts don't have any picture?
Apparently, some of the names in the Excel file have some extra information which makes the app crash sometimes. Your code worked properly. Thanks!
My pleasure! Yes, think I've seen that before if Id is blank or not recognised.
Error handling using the IfError function (or similar) is worth looking into: https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-iferror
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.
Jump in, show your community spirit, and win prizes!
Expanding mentorship, skilling, and AI innovation
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Valantis 474
WarrenBelz 375 Most Valuable Professional