Hi Community,
I've been trying to get a sensible solution for this. But after looking at so many posts and solutions I felt like I had to post one for my scenario.
I have an app, connected to a SharePoint list, which has a form with which I update the list with some basic values like Yes/No and other choices. This form has a Submit button. I want to capture the username of the user who submits this form by clicking the Submit button. The SharePoint list already has a 'Person or Group' type column to capture this information.
I've tried the below in the OnSelect property of the Submit button:
Patch(
DataSource,
Defaults(DataSource),
{
'Submitted by': {
Claims: "i:0#.f|membership|" & User().Email,
}
}
);
SubmitForm(Form)
where, 'Submitted by' is the "Person or Group" column name in the SharePoint list. I get the error: "The type of this argument 'Submittedby' does not match the expected type 'Table'. Found type 'Record'."
What else do I need to do? I basically want to capture the name of the logged in user who clicks on the Submit button to submit the form.
I even tried the simpler version of this where I added a 'single line of text' column and used
Patch(DataSource, Defaults(DataSource), {'Action Submitted by': User().FullName});
SubmitForm(Form)
where, 'Action Submitted by' is the 'single line of text' column.
Even this didn't work.
Patch(
'DataSource',
Defaults('MDataSource'),
{
'Action Submitted by': "Test"
}
);
SubmitForm(Form)
There are no errors, but the column remains blank.
I'm sorry, I couldn't follow that post. If anything, it confused me even further. It's possibly because I don't have the level of expertise in PowerApps to comprehend it. I'm going to go to Microsoft support for this one. I need a bit of a hand-holding, I guess. But thanks for the prompt replies.
In that case you will want to create a new Person field in your SharePoint list, and then follow the steps in this article to save the current logged in user to this field.
https://piyushksingh.com/2019/03/29/powerapps-select-current-user-by-default/
There are a number or articles and videos that will step through how to do this, but the one above seemed relatively straight forward. I have done this numerous times, so this is very doable.
This might not work for me because the SharePoint list is also a data source that is being populated by a Flow. It already has the Created by column filled with my name. Unless this updates that column with the logged on user in the Power app, this won't work.
This record only assumes that you are using the SubmitForm() function. It does not matter if it is a new record or Edit Record. However, if you just need to see the submitter, you don't even need to do that. You can either just add the 'Created By' field into your form, or you can reference it by adding a label into your form, then use ThisItem.'Created By'.Email. Its a field that can be used just like any other field in SPO, except it is read-only,
To answer your question, the second Set variable function can be used anywhere (not just in OnSuccess). You don't even need to set a variable, you can just reference it by using the formula in a label (or anywhere else you need to use it).
varLastRecord.'Created By'.Email
@Anchov does this solution assume I'm creating a new record in the SP List? I'm not. The form is a detail screen for a gallery which contains other fields that are not editable. I have 3 fields that users can edit (drop-down and free text) and hit the Submit button.
Now, in your solution, do both the Set functions go in the OnSuccess property of the form?
The easiest way to retrieve the person who submitted the form is to use the Created By column, which is system generated by SharePoint. You can get the name, email, etc, from the LastSubmit function. For example, let say you have a button with a SubmitForm(Form1). When this is clicked, the form submits to SharePoint. The form has a property called OnSuccess. This runs after the form is succesfully saved to SharePoint.
In the form OnSuccess property , add the following formula:
Set(
varLastRecord,
Form1.LastSubmit
);
You can then retrieve the value of the 'Created By' field by using the object selector like:
Set(varSubmitterEmail, varLastRecord.'Created By'.Email)
Hope this helps.
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Cheers!
Rick Hurt
The easiest way to retrieve the person who submitted the form is to use the Created By column, which is system generated by SharePoint. You can get the name, email, etc, from the LastSubmit function. For example, let say you have a button with a SubmitForm(Form1). When this is clicked, the form submits to SharePoint. The form has a property called OnSuccess. This runs after the form is succesfully saved to SharePoint.
In this form, add the following formula:
Set(
varLastRecord,
Form1.LastSubmit
);
You can then retrieve the value of the 'Created By' field by using the object selector like:
Set(varSubmitterEmail, varLastRecord.'Created By'.Email)
Hope this helps.
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Cheers!
Rick Hurt
WarrenBelz
637
Most Valuable Professional
stampcoin
570
Super User 2025 Season 2
Power Apps 1919
473