Canvas Apps Expressions

Office365Users Connector – Get rid of this warning!

User profile using Office365 connector
User profile using Office365 connector

Background - Office365Users connector

The Office365Users connector provides a rich set of functions that can provide information like,

  1. profile of the current or another user (MyProfileV2, UserProfileV2)
  2. user photo of the current or another user (UserPhotoV2)
  3. manager of a user (ManagerV2)
  4. direct reports of a user (DirectReportsV2)

A common use case is to have a gallery of users, showing their profile photos using the Office365Users connector.

The problem - An error with Office365Users.UserPhotoV2

Assume that there is a gallery with its data source set to the Users Dataverse table. To display each user's photo, set the image property of an image control within the gallery to:

Office365Users.UserPhotoV2(ThisItem.'User Name')

While this expression works fine and the user profile photos do show up, a runtime error shows up both within the studio and when playing the app. The error message is: "The method 'UserPhotoV2' has an invalid value for parameter 'id'". In a newer authoring version, I saw the following error message as well: "UserPhotoV2 failed: {"statuscode": 404, "message": "Resource not found"}".

The resolution

After spending a lot of time trying to figure why the user name that I was passing could be "invalid", I found out that it is complaining that ThisItem.'User Name' could be blank for some users. So to get rid of this error, all I had to do was to change the Image property to:

If(
    !IsBlank(ThisItem.'User Name'),
    Office365Users.UserPhotoV2(ThisItem.'User Name'),
    SampleImage
)

This basically ensures that the UserPhotoV2 function will not be called if ThisItem.'User Name' is blank. To summarize, if you are using any Office365Users function in which you have to pass an id, make sure the parameter is not blank.

Recent articles

  1. Weird combo box OnChange behavior – Should it trigger or not?
  2. Power Apps galleries – how to auto scroll!
  3. Make your Power Apps sessions persistent when switching Teams tab!

6 thoughts on “Office365Users Connector – Get rid of this warning!”

  1. I have tried this way but i am still getting error while running the app.
    Office365Users.UserProfile failed: { “status”: 404, “message”: “No user found with the specified id.\r\nclientRequestId: 845e227f-8da4-4ca0-9233-27c0c06a316f\r\nserviceRequestId: 913a17e9-7bb5-4702-86f1-b8bbeaef088d”, “error”: { “message”: “No user found with the specified id.” }, “source”: “office365users-si.azconn-si.p.azurewebsites.net” }

  2. Thank you so much – this was ‘bugging’ me for ages!!! My app was working for a year before it started throwing this error. Now fixed!!!

Leave a Reply