I was developing a Power Apps survey form recently, and there, I encountered an issue while displaying the current logged-in user name in a combo box inside the new form. Also, I tried out different formulas to show the logged-in user name by default inside the combo box control, but it didn’t work out anything for me.
Even if the applying formula was correct and the combo box also displayed the current user name, at the same time, while submitting the form, the user name was not saved in the SharePoint list field.
Finally, I found and tried some tricky ways and got the expected result. Also, the username of the current logged-in user is saved correctly in the SharePoint Person column.
In this article, I will tell you how to show the current logged in user in a Combo box on a Power Apps Modern form and save this value in a SharePoint Person field with a simple scenario.
Show the Current Logged In User in a Combo Box On a Power Apps Modern Form
Let me describe the scenario and how to display the current logged-in user in the Power Apps combo box inside the modern new form.
Set up a SharePoint List
I have a SharePoint list named Employee Survey Form that contains the fields below:
Column | Data type |
---|---|
Employee Full Name | Person |
Employee Email | Single line of text |
Contact Number | Number |
Current Location | Choice [Australia, Brazil, Canada] |
Age | Number |
Add a Power Apps New Form [Modern Control]
In Power Apps, add a Power Apps Modern Form control and connect the specific SharePoint list to the new form.
Now, I want to display the current logged-in user’s full name inside the combo box (Employee Full Name) by default when a user opens the app. Also, the user’s full name should be saved in the SharePoint list once we click the Save button.
Wherever the Employee Full Name Combo box’s Items property (by default) is:
Items = Choices([@'Employee Survey Form'].'EmployeeFullName')
Then I tried some of the formulas in Combobox’s DefaultelectedItems property that didn’t meet my requirements, and finally, I found a tricky solution, which I have explained below.
NonWorking Formulas
First, let me tell you all the formulas I have found and tried but did not get proper results.
Formula [Combobox’s DefaultelectedItems Property] | Screenshot | Description |
---|---|---|
[Parent.Default] | It did not display the current logged-in user name, nor was it saved in the SharePoint list. | |
User().FullName | It shows an error as “Expected Table Value.” | |
{Value: User().FullName} | This code shows an unexpected value in the combo box control even after adding the Display Name from the Edit section (from the Properties pane). | |
Filter(Distinct(‘Employee Survey Form’, ‘Employee Full Name’.DisplayName), Value = User().FullName) | This formula neither shows any current logged-in user name nor gives any error. | |
Coalesce(Parent.Default, {Claims: “i:0#.f|membership|”&User().Email, Department:””, DisplayName:User().FullName, Email:User().Email, JobTitle:””,Picture””}) | This code shows the current logged-in user, but it does not save in the SharePoint person field after saving the value. |
Apply the Formula on Combobox’s DefaultSelected Property & Update the Datacard
Finally, I achieved this by using the formula below. Also, we need to update the Combo Box data card to save the name in the SharePoint list.
Select the Employee Full Name Combobox control and set its DefaultSelectedItems property as:
{DisplayName:User().FullName}
Next, go to the Properties pane -> Display -> Edit (from Fields) -> + Add field -> Select DisplayName -> Add as shown below.
Select the Employee Full Name Data card and set its Update property as: [You can comment on the default code first, like DataCardValue12.Selected]
{Claims:"i:0#.f|membership|" & User().Email,Department:"",DisplayName:"",Email:"",JobTitle:"",Picture:""}
Now it’s done.
Submit the Power Apps Form & Save Combobox Value in the SharePoint Person Field
Finally, to save the Power Apps form field values, insert a Power Apps modern button control and set its OnSelect property to the code below:
OnSelect = SubmitForm(SurveyForm); NewForm(SurveyForm); Notify("Your Survey Details Has Been Saved Successfully",NotificationType.Success);
Where,
SurveyForm = Power Apps Edit Form Name
Just Save and Publish the application. Preview the form and enter the details except the Employee’s Full name because it will display the current user name by default. Click on the SAVE button.
Next, we will get a successful notification that our survey details have been saved successfully in the SharePoint list.
Go to the specific SharePoint list and refresh it. The Power Apps current logged-in user’s full name has been saved in the Person field, as in the screenshot below.
I hope this article is beneficial to you. This way, we can show the currently logged-in user’s full name by default in the combo box control and store its value in a SharePoint person field.
Also, you may like some more Power Apps articles:
- Concatenate Power Apps Combo Box Value With a Custom Value
- 9 Useful Power Apps Form Validations Examples
- Power Apps Login Page Forgot Password Feature
- Power Apps Split String into Repeating Table
- Trigger an Action When the Enter Key is Pressed in Power Apps
- Show/Hide Password in Power Apps Login Page
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