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

PowerApps People picker - Current User

I have a people picker field in the SharePoint list and I am displaying that in PowerApps in New Form. Users should be able to enter user name and submit the form. It is working as expected.

 

Also, I would like this people picker to show current user name by default when new form shows up and if user doesn't change this in the people picker, it should just save current user name in the people field in SharePoint. I know that I can display current user by User().DisplayName but I am not sure where to put that. I have tried adding it in the Default property but that is not working. It is giving an error property expects record value but this produces a text value. 

2 ACCEPTED SOLUTIONS

Accepted Solutions

@Dvictor881,

 

Sorry for the confusion. It looks like I gave you my manager lookup formula. It is checking to see if it is a new form and if so, setting the default value to the current user's manager. The user can still change the value if needed. I have updated the code to display the current user instead of manager.

 

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


--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

View solution in original post

martinav
Super User
Super User

Not sure if this has changed since it was first posted, but using User() with no . descriptor in the DefaultSelectedItems now works for the current user name in a people picker field.  I think this answers the original question.

 

If(EditForm2.Mode = New,User(),Blank())

Works the same as the other solution, but you dont need all the stuff in the squigglies.

View solution in original post

38 REPLIES 38
Jeff_Thorpe
Super User
Super User

Try this code in the default property of the data card associated with the people picker field. You will also need to change the PeoplePicker in the last line to the name of your people picker field.

 

If(SharePointForm1.Mode = New,{
  '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
   Claims:Concatenate("i:0#.f|membership|",Office365Users.Manager(User().Email).Mail),
   DisplayName:Office365Users.Manager(User().Email).DisplayName,
   Email:Office365Users.Manager(User().Email).Mail
    }, 
ThisItem.PeoplePicker)

 

Why do smiley faces keep showing up and do you stop it.  Where ever you see a smiley face replace it with ":" and "O"



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
Sienna
Resident Rockstar
Resident Rockstar

😆 @Jeff_Thorpe
There is setting under your account to stop the smiley faces show up. But I think that should be set as default not to show these faces.. Specialy in the code. Tag someone who is resposible for this to fix it. It is really annoying

Thanks for replying. I haven't tried it yet but just by reading it, it looks like it is checking if the form is new show current user managers information otherwise show people picker. Is that correct?

 

Basically, I only have new form and no other form. In New form itself, I want default to be current user name and user should have ability to change that to some other name and that's where people picker shows up. 

 

 

@Dvictor881,

 

Sorry for the confusion. It looks like I gave you my manager lookup formula. It is checking to see if it is a new form and if so, setting the default value to the current user's manager. The user can still change the value if needed. I have updated the code to display the current user instead of manager.

 

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


--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

@Sienna,

 

Thanks for the tip on the smile setting and I have turned it off. I agree it should be off by default or at the very least it should display in code box.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Thanks for the help. It worked perfectly. I have included this code in the DefaultSelectedItems property and it is behaving as expected. Thanks again. 

Anonymous
Not applicable

Hi,

 

Is this still the only way to get the current user pre-selected in a people picker drop-down? If so, is there a way to use the selected user information to then populate an email field (single line of text field)?

 

Thanks!

H

 

 

@Anonymous

Since email is property of the selected person record in the people picker you can get the email address and display it in a text field. If the people picker was single select and in a combo box called DataCardValue1 the formula would look like this:

 

DataCardValue1.Selected.Email


--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
Anonymous
Not applicable

Fabulous! Thanks!

Helpful resources

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

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (2,767)