cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Guyto
Level: Powered On

Office365Users.UserProfile many errors (Please Reply)

 

If(!IsBlank(Office365Users.UserProfile(ThisItem.Employee_x0020_Name.Email).Id) && Office365Users.UserPhotoMetadata(Office365Users.UserProfile(ThisItem.Employee_x0020_Name.Email).Id).HasPhoto, Office365Users.UserPhoto(Office365Users.UserProfile(ThisItem.Employee_x0020_Name.Email).Id),imgfaux)

The above pulls the employees Office365 profile photo without issues but randomely produce the error below:

Office365Users.UserProfile failed: The server returned an HTTP error with code 0

 

So I did some research and I found, within this General Discussion Board a technique to use context:

UpdateContext({UserProfile: Office365Users.MyProfile() });UpdateContext ({Manager: Office365Users.Manager(UserProfile.Id)});

and the below on the onvisible formula container of the screen

 

{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:Concatenate("i:0#.f|membership|",Manager.Mail),
Department: Manager.Department,
DisplayName: Manager.DisplayName,
Email: Manager.Mail,
JobTitle: Manager.JobTitle,
Picture:""
}

Remember, I use SharePoint as my datasource to pull the data needed and displaying the data within a powerapps gallery.

 

I really need someone to help me figure this out. If I have to have an engineer at microsoft to access my app to look at the code within it, I would be delighted to do so. I love using your tools (PowerBI, Powerapps) but please help me figure this out. The user profile images come through on the gallery but the errors make them disappear many times.

 

Someone please reply. The app I created is quite critical and I need the assistance ASAP!!!!

9 REPLIES 9
bdodu
Level 8

Re: Office365Users.UserProfile many errors (Please Reply)

I did the same thing for several applications and the lesson learned here was that be sure:

- first to collect needed data in a collection in order to perform in memory fastest

- second you start using the Office365Users connector only after all the collection is fully populated. Most of the errors come from the searching for a profile with null values in UserPhotoMetadata function.

 

Try to comment the using of the function and see if your code works without it.

 

If not succesfull than try my method for a smaller test collection. Don't forget to check the collection has all the valid values within.

 

PS. your code:

 

Office365Users.UserPhotoMetadata(Office365Users.UserProfile(ThisItem.Employee_x0020_Name.Email).Id).HasPhoto

Can you imagine what happens if UserMetadata() returns null? You receive that error message correct?

 

Guyto
Level: Powered On

Re: Office365Users.UserProfile many errors (Please Reply)

Thank you for replying to my issue. I will provide updates as to solutions. Can you perhaps provide a concrete example of the collection method you used.

 

To your question:

Can you imagine what happens if UserMetadata() returns null? You receive that error message correct?

Yes I do receive that error message. 

 

bdodu
Level 8

Re: Office365Users.UserProfile many errors (Please Reply)

Ok, first of all you load one collection with the users you want from sharepoint. Let's say you load:

 

ClearCollect( users, your_sharepoint_users_datasource)

Be sure you include at least First Name, Last Name, and email address. Hope you did it before and you have no issues so far with this step.

The you add a column name UserPrincipalName which you load with user emails (hope your organization has the login the same as the email address otherwise you have to be sure you are working with the login and not with the email). That's why I callled the column UserPrincipalName:

 

ClearCollect(AdjustedUsers,AddColumns(users,"UserPrincipalName", users.Email) )

 

Now for instance if you have a gallery in the template row you include a picture and you bind the Image property to:

 

Image = If(IsBlank(ThisItem.UserPrincipalName), 
'default-profile-icon',
If(!Office365Users.UserPhotoMetadata(ThisItem.UserPrincipalName).HasPhoto, 'default-profile-icon', Office365Users.UserPhoto(ThisItem.UserPrincipalName) )
)

In my case 'default-profile-icon' is a picture I use for a blank image in case the user has no photo set up. I've loaded it previously in File / Media menu. 

 

If you are still getting the errors please start checking your users collection. You may find null values, may be not existing users, etc.

Guyto
Level: Powered On

Re: Office365Users.UserProfile many errors (Please Reply)

Greetings bdodu,

 

You information is quite splendid. I am now exploring the "Collection" approach and will soon provide you updates as to resolution. A question, how can I pull the data for all Office365Users data into a collection table using the ClearCollect Method?. My users are not from the SharePoint site but from the Office365 tenant.

bdodu
Level 8

Re: Office365Users.UserProfile many errors (Please Reply)

Glad that you liked it - that are kudos for Smiley Happy
You can either use Office365Users.SearchUser({searchTerm:""})
Or use Azure AD function Getgroupmembers:
https://outlook.office.com/api/beta/me/people/?$top=1000&$Select=DisplayName
First option might be more suitable for less than 100 users
Guyto
Level: Powered On

Re: Office365Users.UserProfile many errors (Please Reply)

Greetings bdodu,

I tried the ClearCollect() method and was able to pull the Office365USers in formation into a collection table but it only displays a preview of the first 5 items. How can I display all the items? I guess I must create a Gallery and have its items property set to the Collection table name? I am assuming to be correct. You were correct, the use of a collection dramatically increases my powerapps performance. I also noticed that upon adding the ClearCollect in the AppStart code container the Word "Getting Your Data" comes under my app's logo at starup. That is interesting so in order words, the data is populated into a table (Collection) then the app opens up where all other calculations are derived from the collection list of items. (This is great.) 

 

My last question: cAn the Microsoft engineers find a way to allow the Office365Users.UserPhotoV2 to display regardless of whether the user has a photo or not? This will eliminate so many issues with photos not displaying or error poping up randomely.

 

 

bdodu
Level 8

Re: Office365Users.UserProfile many errors (Please Reply)

Please write here the code you tried with ClearCollect -  there is not existing a 5 rows limitation at all and I need to understand what's wrong with your code.

 

Did you manage to get rid of the errors as you asked in you starting question?

 

I am not a Microsoft engineer so I cannot help you with the improvemen but of course any idea you may have should be listed in the Power Apps-Ideas if not existing already.

Guyto
Level: Powered On

Re: Office365Users.UserProfile many errors (Please Reply)

Greetings bdodu,

 

I am not implying 5 row limitation. All the records are pulled except that in the Collection table view it shows a "Preview" of the 5 first items. The code that I devised works as it pulls the data and I can see them in the collection table. I got rid of some of the errors. I assigned variables using the set() method and errors are starting to no logner come through because I am pulling from the collection.

 

Thanks.Smiley Happy

AM0002
Level: Powered On

Re: Office365Users.UserProfile many errors (Please Reply)

I have had a similar issue with using If(!IsBlank(Thisitem.Email),Office365Users.UserPhotoV2(ThisItem.Email),SampleImage) after much searching forums, I finally stopped the error occuring by removing the reference to 'ThisItem'  so the formula now says If(!IsBlank(Email),Office365Users.UserPhotoV2(Email),SampleImage) and is not generating any errors. Hope this helps anyone with this particualr issue as some of the other resolutions did not work for me. 

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, September 18th at 8am PDT

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 37 members 4,501 guests
Please welcome our newest community members: