When building canvas apps in Power Apps that integrate with SharePoint or Dataverse, you may need to pre-populate certain fields with default values. One such field is the Person field or People Picker Field, which allows users to select a person or group.

You can read more about the data sources comparison in the Microsoft Learn

Click on the button below to explore the website.

Explore the website

SharePoint

In SharePoint, you can populate the default value of a Person field using a JSON string that specifies the person's display name, email address, and other properties. You need to assign the default value to the DefaultSelectedItems property of the people picker. Here's an example of the JSON string format:

{   
    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    Claims: "i:0#.f|membership|" & Lower(User().Email),
    DisplayName: User().FullName,
    Email: User().Email 
} 

Dataverse

In Dataverse, the process is similar, but the value you assign to the DefaultSelectedItems property depends on the table you use for your Person field. For example, if you're using the AAD Users table, you can use the following expression:

Filter('AAD Users',Mail = User().Email)

Conclusion

In conclusion, pre-populating the default value of a Person field in a SharePoint or Dataverse canvas app is easy once you know the correct JSON string or expression format. By doing so, you can save users time and effort when filling out forms and ensure that the data in your app is consistent and accurate.