cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NamegomJan
Helper II
Helper II

ErrorMessage The method 'UserPhotoV2' has an invalid value for parameter 'id'

Hi everyone,

 

I browsed the whole community, and many had the same error message but none of the solutions worked.

 

The situation:

 

I have a gallery with a sharepoint list as a data source. The field "SendFrom" is a "Person or Group" field. I am retrieving the User Name from that "Send From" field and retrieving the Office365 Profile Picture through this. 

 

By the way I am in Germany so thats why the Office365 user syntax is different and some other syntax differences. This is the code I am using:

 

If('Office365-Benutzer'.UserPhotoMetadata(ThisItem.SendFrom.Email).HasPhoto=false;SampleImage;'Office365-Benutzer'.UserPhotoV2(ThisItem.SendFrom.Email))

 

It shows me the profile picture. And for those that don't have a profile picture, it shows the sample image. So that works.

 

However I am still getting two error messages:

The method 'UserPhotoV2' has an invalid value for parameter 'id'

The method 'UserPhotoMetadata' has an invalid value for parameter 'userid'

 

I tried different additional approaches based on the solutions that I found here:

 

1. 'Office365-Benutzer'.UserPhotoV2(ThisItem.SendFrom.Email) -->1 Error Message + However does not show sample image in case the user has no profile picture.

2. If(IsBlankOrError('Office365-Benutzer'.UserPhotoV2(ThisItem.SendFrom.Email));SampleImage;'Office365-Benutzer'.UserPhotoV2(ThisItem.SendFrom.Email)) -->  1 Error Message + Sample Picture will not be shown in development mode but in the app you will see it.

3. If(IsBlank(ThisItem.SendFrom.Picture);'profilepic-generic-user';If('Office365-Benutzer'.UserPhotoMetadata(ThisItem.SendFrom.Email).HasPhoto=false;SampleImage;'Office365-Benutzer'.UserPhotoV2(ThisItem.SendFrom.Email))) --> Shows nothing. Faulty Code.

4. If(IsBlank('Office365-Benutzer'.UserPhotoV2(ThisItem.SendFrom.Email).ID);'profilepic-generic-user';If('Office365-Benutzer'.UserPhotoMetadata(ThisItem.SendFrom.Email).HasPhoto=false;SampleImage;'Office365-Benutzer'.UserPhotoV2(ThisItem.SendFrom.Email))) ---> Shows nothing. Faulty Code

 

Any ideas?

 

Thank you so much!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

@NamegomJan ,

 

Oups ...Sorry for my formula, the ThisItem.SendFrom.Email is string not record, please reconsider to this form:

 

If(IsEmpty('Office365-Benutzer'.SearchUserV2({searchTerm:ThisItem.SendFrom.Email}).value) || IsBlank(ThisItem.SendFrom.Email);SampleImage;'Office365-Benutzer'.UserPhotoMetadata(ThisItem.SendFrom.Email).HasPhoto;'Office365-Benutzer'.UserPhotoV2(ThisItem.SendFrom.Email);SampleImage)

View solution in original post

9 REPLIES 9
gabibalaban
Dual Super User
Dual Super User

Hi @NamegomJan ,]

 

The Office365User.UserPhotoMeta throws an error if the parameter is wrong ( the user mail provided is not in the O365 tenant), also  Office365Users.UserPhotoV2  throws an error if the parameter is wrong ( the user mail provided has no image set), so you have to avoid both of this kind of error you have to check first if the user's email is in the O365 tenant.

For this you have to search the user with Office365Users.SearchUserV2({searchTerm:"email"}).value

So the formula became:

If(

    IsEmpty(

            Office365Users.SearchUserV2({searchTerm:ThisItem.SendFrom.Email}).value),

          SampleImage,

   Office365Users.UserPhotoMetadata(ThisItem.SendFrom.Email).HasPhoto,             

          Office365Users.UserPhotoV2(ThisItem.SendFrom.Email),

           SampleImage

)

 

Please forgive me, but i really don't know how to transform this in German way of coding 😊.

 

Hope it helps !

Hi @gabibalaban ,

 

thank you!!

 

I used the following code as per your suggestion: 

 

If(IsEmpty('Office365-Benutzer'.SearchUserV2({searchTerm:ThisItem.SendFrom.Email}).value);SampleImage;'Office365-Benutzer'.UserPhotoMetadata(ThisItem.SendFrom.Email).HasPhoto;'Office365-Benutzer'.UserPhotoV2(ThisItem.SendFrom.Email);SampleImage)

 

It still gives me one error message:

 

"The method 'UserPhotoMetadata' has an invalid value for parameter 'userid'

 @NamegomJan  - Is there any posibility to have blanks  value in SendFrom.Email ? 

Actually there are no blank entries in sendfrom. At the moment there are 21 entries from 4 different persons. Each of them has corresponding email-addresses. Thats why I would not expect any blank value.

Hi @NamegomJan ,

 

This is my last try 😊 ...I had a test on my side and everything works fine (no matter if the email is from inside or outside the tenant).

 

If(IsEmpty('Office365-Benutzer'.SearchUserV2({searchTerm:ThisItem.SendFrom.Email}).value) || IsEmpty(ThisItem.SendFrom.Email);SampleImage;'Office365-Benutzer'.UserPhotoMetadata(ThisItem.SendFrom.Email).HasPhoto;'Office365-Benutzer'.UserPhotoV2(ThisItem.SendFrom.Email);SampleImage)

 

After you update the formula, please save and publish the app, and open it in PLAY mode.

 

Thank you. Still the same error unfortunately ..

Maybe another hint. This gallery should show the credit balance for a specific user. Sometimes there is no entry in the respective sharepoint list for that specific user and that is where the error message comes from I guess?

 

The current code I am using:

 

If(IsEmpty('Office365-Benutzer'.SearchUserV2({searchTerm:ThisItem.SendFrom.Email}).value);SampleImage;'Office365-Benutzer'.UserPhotoMetadata(ThisItem.SendFrom.Email).HasPhoto;'Office365-Benutzer'.UserPhotoV2(ThisItem.SendFrom.Email);SampleImage)

 

Current error message:

The method 'UserPhotoMetadata' has an invalid value for parameter 'userid'

 

I guess he is stuck in this part "'Office365-Benutzer'.UserPhotoMetadata(ThisItem.SendFrom.Email).HasPhoto" because he wont find any user because the sharepoint list has no entry for this specific user yet.

 

Any ideas? Thanks!

 

@NamegomJan ,

 

Oups ...Sorry for my formula, the ThisItem.SendFrom.Email is string not record, please reconsider to this form:

 

If(IsEmpty('Office365-Benutzer'.SearchUserV2({searchTerm:ThisItem.SendFrom.Email}).value) || IsBlank(ThisItem.SendFrom.Email);SampleImage;'Office365-Benutzer'.UserPhotoMetadata(ThisItem.SendFrom.Email).HasPhoto;'Office365-Benutzer'.UserPhotoV2(ThisItem.SendFrom.Email);SampleImage)

Thank you so much. This worked!!

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (1,913)