CRM Crate

Populate a default value in SharePoint’s person column of Canvas App

In this course, we will learn to populate the currently logged user as a default value in SharePoint’s person column of Canvas App. Before we start, make sure to subscribe to CRM Crate so that you can stay up to date in the field of Power Platform.

Populate the currently logged user

Understanding the “Person” type column in SharePoint / Lists

The “Person or Group” column in SharePoint Online is used to get user or group value. This field can be configured to accept any value from the authentication provider, such as the Active directory, or can be restricted to fetch individuals from a particular SharePoint group.

Why do we need to populate a default value in the Person Column of Canvas App?

Consider a business scenario where the Canvas App‘s logged-in user needs to get auto-populated in the “Person” column of the Canvas App. We can achieve such requirements with the help of the below given PowerFX solution.

For demonstration purpose, we will populate the value of the currently logged-in user as a default value in the Person column named “Who Am I?”.

PowerFX Code for populating a default value in the Person column of SharePoint list

Follow the below steps for auto-populating the value of the logged-in user in the Person column of SharePoint list.

  • Navigate to the Power Apps studio (https://make.powerapps.com/) and open the Canvas App which contains the form/field pointing to the SharePoint list as its data source.
  • Navigate to the column type as “Person” (Who Am I) and navigate to its “DefaultSelectedItem” property as shown below.
  • Now, use the below given PowerFX code for auto-populating the currently logged-in user in the Person column / field.
If(
    Form.Mode=FormMode.New,
    {
        DisplayName: User().FullName,
        Claims: "i:0#.f|membership|" & Lower(User().Email)
    },
    Parent.Default
)
  • Save & publish the Canvas App once the above configurations are completed.

Play the Canvas App and validate the above implementation

Go the the Power Apps studio (https://make.powerapps.com/) and play the Canvas App. Verify if the currently logged-in user is getting auto-populated in the Person column of SharePoint list as shown below.

Thus, we learned to populate a default value in SharePoint’s person column of Canvas App.

5 1 vote
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
error: CRM Crate Security Engine - Disabled Right Click & Selection!

Congratulations!

Well Done,
Welcome to CRM Crate

Stay tuned with us and get all latest updates and learning in Microsoft CRM and related techonologes.