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
KrishnaV
Community Champion
Community Champion

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

9 REPLIES 9
KrishnaV
Community Champion
Community Champion

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()

KrishnaV
Community Champion
Community Champion

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.
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?

KrishnaV
Community Champion
Community Champion

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.

 

KrishnaV
Community Champion
Community Champion

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

 

 

Hello Sir , You are Godlike! and saved my life , i dont know How could i thx you enough ...

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,850)