cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ChrisSullivan
Helper III
Helper III

Office365Users.UserProfileV2 failed: The method 'UserProfileV2' has an invalid value for parameter 'id'

I am getting random: 

 

Office365Users.UserProfileV2 failed: The method 'UserProfileV2' has an invalid value for parameter 'id'

 

I have a gallery showing user info for the person selected in a people picker. 
The Items for the gallery are set as. 
I'm not seeing why i am getting the error. It happens only once and awhile and not for any specific User chosen. 

If(Form2.Mode = FormMode.New && IsBlank(DataCardValue29.Selected),
         {
             '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
              Claims:"i:0#.f|membership|" & Lower(Office365Users.MyProfileV2(User()).mail),
              Department:Office365Users.MyProfileV2(User()).department,
              DisplayName:Office365Users.MyProfileV2(User()).displayName,
              Email:Office365Users.MyProfileV2(User()).mail,
              JobTitle:Office365Users.MyProfileV2(User()).jobTitle,
              Picture: Office365Users.UserPhotoV2(User().Email),
              ID:Office365Users.MyProfileV2(User()).id
         },{
             '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
              Claims:"i:0#.f|membership|" & Lower(Office365Users.UserProfileV2(DataCardValue29.Selected.Email).mail),
              Department:Office365Users.UserProfileV2(DataCardValue29.Selected.Email).department,
              DisplayName:Office365Users.UserProfileV2(DataCardValue29.Selected.Email).displayName,
              Email:Office365Users.UserProfileV2(DataCardValue29.Selected.Email).mail,
              JobTitle:Office365Users.UserProfileV2(DataCardValue29.Selected.Email).jobTitle,
              Picture:Office365Users.UserPhoto(DataCardValue29.Selected.Email),
              ID:Office365Users.UserProfileV2(DataCardValue29.Selected.Email).id
         })

 

 Any thoughts?

5 REPLIES 5
Pstork1
Dual Super User
Dual Super User

Are any of the people in the people picker external users?  And have you verified that all users have email addresses that are the same as their User Principal name?



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Join me at 365 and PWR EduCon in Chicago
EduCon Chicago 2022

Yes all the Users are internal. And, yes there emails are the same as there principal names. This happens at random. I can go between screens that show the same user multiple times, and then randomly I get this error. The App works as designed but I get the ugly error message. 

 

I was wondering if there was a more stable way to call the 'id'?

v-albai-msft
Community Support
Community Support

Hi @ChrisSullivan 
I used to meet this error, finally I add a condition to check if parameter inside Office365Users.UserProfileV2 function is blank before getting user profile value, and this works well.


So I would suggest you try this formula, just add a condition before getting selected user info:

If(Form2.Mode = FormMode.New && IsBlank(DataCardValue29.Selected),
         {
             '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
              Claims:"i:0#.f|membership|" & Lower(Office365Users.MyProfileV2(User()).mail),
              Department:Office365Users.MyProfileV2(User()).department,
              DisplayName:Office365Users.MyProfileV2(User()).displayName,
              Email:Office365Users.MyProfileV2(User()).mail,
              JobTitle:Office365Users.MyProfileV2(User()).jobTitle,
              Picture: Office365Users.UserPhotoV2(User().Email),
              ID:Office365Users.MyProfileV2(User()).id
         },
Form2.Mode <> FormMode.New && !IsBlank(DataCardValue29.Selected.Email),
{
             '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
              Claims:"i:0#.f|membership|" & Lower(Office365Users.UserProfileV2(DataCardValue29.Selected.Email).mail),
              Department:Office365Users.UserProfileV2(DataCardValue29.Selected.Email).department,
              DisplayName:Office365Users.UserProfileV2(DataCardValue29.Selected.Email).displayName,
              Email:Office365Users.UserProfileV2(DataCardValue29.Selected.Email).mail,
              JobTitle:Office365Users.UserProfileV2(DataCardValue29.Selected.Email).jobTitle,
              Picture:Office365Users.UserPhoto(DataCardValue29.Selected.Email),
              ID:Office365Users.UserProfileV2(DataCardValue29.Selected.Email).id
         })

Besides, maybe you need to edit the first condition inside below formula based on your requirement(Depends on when will show selected user info), since I don't know your actual conditions:

Form2.Mode <> FormMode.New && !IsBlank(DataCardValue29.Selected.Email)

Best regards,

Allen

I applied the If statement and I am still getting the error. 

This code is for the Item in a gallery showing User information. Specifically :
DisplayName

Jobtitle

Email

Picture

 

The gallery is pointing to a people picker combo box, If the FormMode.New and nothing is selected from the people picker drop down, then  gather the current users data, Else gather the persons data based on the users email from the drop down. 

 

Im thinking that there must be discrepancies with the id and what actually is the id of the users. All the data seems to be populating just fine. 

ChrisSullivan_0-1622050279184.png

ChrisSullivan_1-1622050372686.png

I tried removing the ID variable, and then I started getting UserPhotoV2 error that points to userID.

 

I'm not sure what is going on to cause this

Hi @ChrisSullivan ,

I have noticed that you are not using ID property in your gallery, if yes, you can remove ID from your code (ID:Office365Users.UserProfileV2(DataCardValue29.Selected.Email).id)

Check this time if you still have some issue. 

Besides, if above still cannot work, I have a simple workaround: remove Picture property from your code, then directly find user picture in image control use this formula(do not use ThisItem.Picture any more):

 

If(
    !IsBlank(DataCardValue29.Selected.Email),
    If(
        Office365Users.UserPhotoMetadata(DataCardValue29.Selected.Email).HasPhoto = true,
        Office365Users.UserPhotoV2(DataCardValue29.Selected.Email)
))

 

v-albai-msft_0-1622105815542.png

Best regards,

Allen

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (5,182)