cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dvictor881
Level: Powered On

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
Super User
Super User

Re: PowerApps People picker - Current User

@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

Super User
Super User

Re: PowerApps People picker - Current 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

29 REPLIES 29
Super User
Super User

Re: PowerApps People picker - Current 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),
   DisplayNameSmiley Surprisedffice365Users.Manager(User().Email).DisplayName,
   EmailSmiley Surprisedffice365Users.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
Level 10

Re: PowerApps People picker - Current User

😆 @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
Dvictor881
Level: Powered On

Re: PowerApps People picker - Current User

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. 

 

 

Super User
Super User

Re: PowerApps People picker - Current User

@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

Super User
Super User

Re: PowerApps People picker - Current User

@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.
Dvictor881
Level: Powered On

Re: PowerApps People picker - Current User

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

Hid
Level: Powered On

Re: PowerApps People picker - Current User

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

 

 

Super User
Super User

Re: PowerApps People picker - Current User

@Hid

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.
Highlighted
Hid
Level: Powered On

Re: PowerApps People picker - Current User

Fabulous! Thanks!

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 51 members 3,471 guests
Please welcome our newest community members: