How to Default a SharePoint Person Column to the Current User in Power Apps
For those diving into Power Apps with SharePoint, setting columns, especially the People columns, can often be a hurdle. The spotlight here is on the “default person” – making the SharePoint Person Column reflect the current user by default. This guide simplifies the process, ensures smooth implementation, and provides an avenue for further assistance if needed.
Video Guide
We’ve prepared a concise 55-second video that visually walks you through the process of setting the SharePoint People column to default to the current user. However, if you prefer textual instructions, they are detailed below.
Steps to Create the Record
The foundational step is correctly setting the ComboBox’s DefaultSelectedItems property:
{ ClaimData: "i:0#.f|memberstatus|" & Lower(CurrentUser().UserMail), Division: "", DisplayName: CurrentUser().UserName, EmailID: CurrentUser().UserMail, RoleTitle: "", Avatar: "" }
This code snippet should seamlessly integrate into your app.
Ensure Defaults Only When Field is Empty
Preserving existing values is crucial. To make sure you don’t unintentionally overwrite them, use the Coalesce function:
Coalesce(ThisItem.Supervisor, { ClaimData: "i:0#.f|memberstatus|" & Lower(CurrentUser().UserMail), Division: "", DisplayName: CurrentUser().UserName, EmailID: CurrentUser().UserMail, RoleTitle: "", Avatar: "" } )
Remember to swap out the “Supervisor” placeholder with the actual name of your Person column.
Defaulting for New Entries Only
In scenarios where you want the current user to be the default only for new entries, employ the following logic:
If(AppForm1.Mode = FormMode.New, { ClaimData: "i:0#.f|memberstatus|" & Lower(CurrentUser().UserMail), Division: "", DisplayName: CurrentUser().UserName, EmailID: CurrentUser().UserMail, RoleTitle: "", Avatar: "" }, ThisItem.Supervisor )
Do replace “AppForm1” and “Supervisor” with the actual names you’re using in your app.
Conclusion
With the steps detailed above, setting a SharePoint Person column to default to the logged-in user in Power Apps should now be a straightforward task. Adaptations might be required based on individual app scenarios, but the core logic remains consistent. In case you encounter any bumps along the way, remember, help is just a click away. Whether you’re looking for quick guidance or in-depth assistance, our team at SoftwareZone365 is equipped to provide the answers. So if a Power problem surfaces, know that we have a powerful solution waiting for you. 😄