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.
Solved! Go to Solution.
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)
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.
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"
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.
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)
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.
Thanks for the help. It worked perfectly. I have included this code in the DefaultSelectedItems property and it is behaving as expected. Thanks again.
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
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
Fabulous! Thanks!
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
203 | |
187 | |
81 | |
50 | |
37 |
User | Count |
---|---|
299 | |
249 | |
124 | |
73 | |
55 |