Power Apps: Set Default Value To SP User Or Group Field


Problem

You can easily set default value to text field, drop down control using Default property in Power Apps forms. But if your are dealing with SharePoint list and you have SharePoint people/group field which you want to get automatically populated value from the context, how can you achieve this ? This control also has Default property but you can not just enter person email or account Id or any other field. This blog explains how we can get that done.

Solution

Have a look on the solution here. I am assuming that you have already created a powerapp custom form using the list custom forms option and you have already added an column of type people/group. If you are not yet done all these steps, I suggest you to customize the list form and reach till the point where form will have all default data cards added to screen. Now, open your PowerApps app. Open the screen which has a Form with Person or Group field added on it. In below screenshot, Employee is Person or Group field. So, my requirement is that whenever users try to add a new record, I want to keep a specific person as selected automatically (default) in Employee field. 

Here are the steps:

  • Select Employee data card
  • Click on “Unlock to change properties” from Advanced menu
  • Select the value control inside the data card as shown below
  • I have selected Employee_DataCard1
  • From left top side drop down many select “Default” property 
  • Below is the format of data, this is how we need to set it; then only it detects it as User object and accepts the input. 
{  
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",  
DisplayName:User().FullName,  
Claims:"i:0#.f|membership|" & Lower(User().Email),  
Department:"",  
Email:User().Email,  
JobTitle:"",  
Picture:""  
}
  • We need to set same value to “DefaultSelectedItems” Property as well. This is required step, as only then will it work.

As you can see in the below screen it shows Mohit Vashishtha users as selected already by default. 

 Once your changes are done. Save the form and do a test to add a new record as shown below. It will show logged on user as selected by default. You can make any user selected by default, it can be current user, current user’s manager or HR manager etc. 

 Happy SharePointing 🙂 along with PowerAppsing !!