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

DefaultSelectedItems for People column in SP list

Hey all,

 

I am building an app where I'm using 2 column formatted as "People" in SP online list

 

I need for one of them to set the default value as the manager of the person who is making the request.

 

I added a form and changed the mode to new.

 

I set a variable on my OnStart like this : Set(varUserManager,Microsoft365Users.ManagerV2(Microsoft365Users.MyProfileV2().id).displayName])

 

Then, on my form's DataCardValue I changed the DefaultSelectedItems value to be varUserManager.Value. This shows up just fine, and I'm able to change it if I want, but if I leave it like this after submitting the form the field in SP remains blank...what am I doing wrong?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Alex_Mateiu ,

 

Here is the code for that:

{
  '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
   Claims:Concatenate("i:0#.f|membership|",Microsoft365Users.ManagerV2(Microsoft365Users.MyProfileV2().id).Email),
   DisplayName:Microsoft365Users.ManagerV2(Microsoft365Users.MyProfileV2().id).displayName,
   Email:Microsoft365Users.ManagerV2(Microsoft365Users.MyProfileV2().id).Email
    }

 
I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

8 REPLIES 8
Super User III
Super User III

Hi @Alex_Mateiu ,

 

Try one these 3 methods to set the default value to People picker field:

If(FormMode.New = 1,{
  '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
   Claims:Concatenate("i:0#.f|membership|",User().Email),
   DisplayName:User().FullName,
   Email:User().Email
    })

OR

    If(FormMode.New =1,Microsoft365Users.MyProfile()) // This require Microsoft365Users connector

OR
// Set this on APP OnStart and then use the variable on DefaultSelectedItems propoerty of the field in the form
Set(requesterClaim,{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
        Claims:"i:0#.f|membership|" & User().Email,
    Department:"",
   DisplayName:User().FullName,
         Email:User().Email,
      JobTitle:"",
       Picture:""
   });    


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

Hello,

 

It doesn't work as intended, my need is to have the Manager of the person using the app , not the User()

Hi @Alex_Mateiu ,

 

Here is the code for that:

{
  '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
   Claims:Concatenate("i:0#.f|membership|",Microsoft365Users.ManagerV2(Microsoft365Users.MyProfileV2().id).Email),
   DisplayName:Microsoft365Users.ManagerV2(Microsoft365Users.MyProfileV2().id).displayName,
   Email:Microsoft365Users.ManagerV2(Microsoft365Users.MyProfileV2().id).Email
    }

 
I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

If you are so kind, could you also help me with a code for a image item? On the same data card I want to input the image of the person ( manager in my case) selected in the datacardvalue ...how do I do that?

Hi @Alex_Mateiu,

try this to an image:

Microsoft365Users.userPhotoV2(Microsoft365Users.ManagerV2(Microsoft365Users.MyProfileV2().id).id)


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

Hello,

 

That works for the default value of the datacard. however, if the user changes the person to someone else, the picture does not.

 

Hi @Alex_Mateiu ,

 

try this:

Microsoft365Users.userPhotoV2(Microsoft365Users.ManagerV2(peoplepickercontrol.Email).id)

 
I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

Hello @KrishnaV ,

 

It actually doesn't...it doesn't like that I reference the datacard.

Alex_Mateiu_0-1596632112628.png

I added the SelectedItems but the error is without also. 

Besides this, I don't need the manager of the person. That value in datacardvalue10 is already the manager of the user.

Alex_Mateiu_1-1596632536198.png

 

 

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (51,875)