Skip to main content
Community site session details

Community site session details

Session Id : RXwyPMEUmv16XNCKPB57q9
Power Apps - Building Power Apps
Suggested answer

Capture username of the user who submitted the form

Like (1) ShareShare
ReportReport
Posted on 20 Apr 2023 18:46:44 by 45

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.

  • Suggested answer
    MSFTPowerNoob Profile Picture
    45 on 14 Nov 2024 at 15:19:02
    Capture username of the user who submitted the form
    I was finally able to get this done (a while back) simply by adding a field in the form called Submitted by which I reformatted to single line of text and setting its items property to User().FullName. I hope this helps someone trying to do the same. Cheers!
  • MSFTPowerNoob Profile Picture
    45 on 28 Apr 2023 at 19:01:43
    Re: Capture username of the user who submitted the form

    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.

  • Anchov Profile Picture
    1,984 on 26 Apr 2023 at 20:50:17
    Re: Capture username of the user who submitted the form

    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.

     

     

  • MSFTPowerNoob Profile Picture
    45 on 26 Apr 2023 at 17:22:45
    Re: Capture username of the user who submitted the form

    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.

  • Anchov Profile Picture
    1,984 on 21 Apr 2023 at 12:34:18
    Re: Capture username of the user who submitted the form

    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

     

  • MSFTPowerNoob Profile Picture
    45 on 21 Apr 2023 at 08:50:10
    Re: Capture username of the user who submitted the form

    @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?

  • Anchov Profile Picture
    1,984 on 20 Apr 2023 at 20:43:33
    Re: Capture username of the user who submitted 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

  • Anchov Profile Picture
    1,984 on 20 Apr 2023 at 20:43:29
    Re: Capture username of the user who submitted 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 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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473

Loading complete