Recently, I was working on a Power Apps requirement and faced a challenging issue saving the Power Apps current user and manager name in the SharePoint Person column.
The strange part is that when we submit a Power Apps form, we can’t directly save the Power Apps current user and manager name [Combo box values] in a SharePoint Person field.
After researching many articles, I found the trickiest solution and implemented it in the Update property of the specific Combo box Data card. And it works really well.
Let’s start it step by step on how to achieve it.
Setup a SharePoint List
Below is a SharePoint list [Traveller Details] with these many columns:
Column | Data type |
---|---|
Title | Single line of text |
Traveler Name | Person or Group |
Supervisor Name | Person or Group |
Contact Number | Number |
Travel Start Date | Date and time |
Travel End Date | Date and time |
Save Power Apps Current User and Manager Name in SharePoint Person Column
The screenshot below represents a Power Apps form [Travel Request]. Both the Person fields [Traveler Name, Supervisor Name] appear with Combo box controls.
Also, both controls are in view mode so that nobody can change/modify them.
Let’s achieve it step by step.
Build Power Apps Form
1. In Power Apps, insert an Edit form and set its DataSource property to the SharePoint list.
DataSource = 'Traveller Details'
2. To display the default current user name (Traveler Name) and Manager name (Supervisor Name), you need to write the codes below on both combo box’s DefaultSelectedItems property:
Traveler Name: DefaultSelectedItems = {DisplayName:User().FullName}
Supervisor Name: DefaultSelectedItems = [Office365Users.ManagerV2(User().Email).displayName]
You need to ensure to connect the Office365Users connector to the app.
3. Add a Button [SUBMIT] and set its OnSelect property as:
OnSelect = SubmitForm(Form1);ResetForm(Form1)
Form1 = Edit form name
4. Save, Publish, and Preview the app. Fill out the travel request form and click on the SUBMIT.
5. Go to the SharePoint list and refresh it once. The strange part is that the current user and manager names are not saved over there. Apart from these two values, all the field values are stored in the SharePoint list, as shown below.
Now, how can we overcome this problem? I researched many articles and found the tricky solution below.
We can’t store the Power Apps current user and manager names directly in the SharePoint person field. To store these two values, we must write a code on both combo boxes’ Datacard Update property.
6. Open the Power Apps Edit form -> go to the Update property of Traveler name Data card -> Remove DataCardValue.Selected and apply the code below:
Update = {
Claims: "i:0#.f|membership|" & User().Email,
Department: "",
DisplayName: "",
Email: "",
JobTitle: "",
Picture: ""
}
7. Similarly, go to the Supervisor Name Datacard’s Update property -> Remove DataCardValue.Selected and add the code below:
Update = {
DisplayName: Office365Users.ManagerV2(User().Email).displayName,
Claims: "i:0#.f|membership|" & Office365Users.ManagerV2(User().Email).userPrincipalName,
Department: "",
Email: Office365Users.ManagerV2(User().Email).userPrincipalName,
JobTitle: "",
Picture: ""
}
8. That’s it to do. Save, publish, and close the app. Play the app and submit a new travel request using the form.
Once you refresh the SharePoint list, you can see that the person field values have been updated, as shown below.
This way, we can save the Power App’s current user and Manager name in the SharePoint Person column.
Some more Power Apps articles you may also like:
- Get Last Item ID in SharePoint List Based on Current User in Power Apps
- Power Apps Search Function Examples
- Power Apps Naming Conventions
- Download File From SharePoint Document Library in Power Apps
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com