In my app, quite often I use the Office365Users function to get information about the user or his/her manager. I noticed that sometimes those functions produce errors while sometimes they work perfectly.
One of the error I get is this:
The service returned an error: Office365Users!Manager: The method ‘Manager’ has an invalid value for parameter ‘userId’
Here is the code where the error occurs:
{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:Concatenate("i:0#.f|membership|",Office365Users.Manager(Office365Users.MyProfile().Id).Mail), Department:Office365Users.Manager(Office365Users.MyProfile().Id).Department, DisplayName:Office365Users.Manager(Office365Users.MyProfile().Id).DisplayName, Email:Office365Users.Manager(Office365Users.MyProfile().Id).Mail, JobTitle:Office365Users.Manager(Office365Users.MyProfile().Id).JobTitle, Picture:"" }
Also quite often I get this error:
The service returned an error: Office365!MyProfile: The server returned an HTTP error with code 0.
Sometimes I get no errors and everything works fine. So, when I get the second error (HTTP) what could be causing it? Because the way I understand it, the Office365MyProfile() function gets an error while trying to retrieve the info on the users, that’s why it throws HTTP error. Of course because MyProfile() function failed so will the Manager as it uses MyProfile() as an input, that’s why I get the first error.
I am thinking could it be our system not sending the info over as I keep requesting it from the server too often? How would I even check that? Is there a way to write the fuction differently to get more info from the errors and why the function is failing?
Also FYI, this function is in a add record form card for a field which is in SharePoint list as Person or Group.
Thanks for any insight!
EDIT: I forgot an important detail. Almost 80% of the time I get NO errors while I do development and launch the app in the PowerApps web development studio. But the app is also embeded in a SharePoint page. And when I test the app on the SharePoint page I get the error 90% of the time. So Strange
Solved! Go to Solution.
I would strongly recommend to move to use a Context variable to store the Id of the user so that it does not call the connector "n" number of times for MyProfile and "m" number of times to Manager(), and avoid the performance hit and the network risk that each call has.
So for that, I would add on the OnVisible of that screen add:
UpdateContext({UserProfile: Office365Users.MyProfile() });
UpdateContext ({Manager: Office365Users.Manager(UserProfile.Id)})
Then your code would look like:
{'@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:"" }
This should be dramatically faster and safer.
I would strongly recommend to move to use a Context variable to store the Id of the user so that it does not call the connector "n" number of times for MyProfile and "m" number of times to Manager(), and avoid the performance hit and the network risk that each call has.
So for that, I would add on the OnVisible of that screen add:
UpdateContext({UserProfile: Office365Users.MyProfile() });
UpdateContext ({Manager: Office365Users.Manager(UserProfile.Id)})
Then your code would look like:
{'@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:"" }
This should be dramatically faster and safer.
You said the code in the first box goes in the OnVisible part of the screen but where does the code in the second box go?
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
206 | |
187 | |
70 | |
37 | |
34 |
User | Count |
---|---|
348 | |
273 | |
122 | |
78 | |
59 |