cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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 @Anonymous ,

 

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.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
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
KrishnaV
Super User
Super User

Hi @Anonymous ,

 

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.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
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.
Anonymous
Not applicable

Hello,

 

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

Hi @Anonymous ,

 

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.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
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

Anonymous
Not applicable

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 @Anonymous,

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.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
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.
Anonymous
Not applicable

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 @Anonymous ,

 

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.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
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.
Anonymous
Not applicable

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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,127)