Live training: next batches coming soon. Join the waitlist:Waitlists open:Developer Training →Developer →Copilot Studio Training →Copilot Studio →

How to Get Last Item ID in SharePoint List Based on Current User in Power Apps?

We usually use the Power Apps LastSubmit function to get the last submitted data from the SharePoint list to Power Apps.

However, in most cases, we might need the last record of the currently logged-in user rather than any other user. Here, the Power Apps LastSubmit() function won’t work anymore because this function always gives the last record from the specific datasource.

In this article, I will explain how to retrieve the last submitted data from the SharePoint list to Power Apps based on logged-in users. Additionally, we will discuss how to show or hide a Power Apps button based on the current user’s last submitted item with a choice value.

Power Apps Display Last Submitted Record For Current User in Display Form

Let’s discuss how to get the last submitted item for the current logged-in user in a Power Apps Display form.

Setup a SharePoint List

Below is a SharePoint list named IT Service Ticket with the columns below:

ColumnData type
NameTitle – Single line of text
EmailSingle line of text
DepartmentChoice [IT, HR, FINANCE, SALES, MARKETING]
Computer IDSingle line of text
Want to Upload Any FileYes/no
Describe the ProblemMultiline
StatusChoice [Approved, Rejected]
Power Apps retrieve last submitted record of current user

Build Power Apps With Forms

In Power Apps, there are two Buttons:

  1. NEW REQUEST: A user will raise a new request with an edit form. The data will be submitted to the above SharePoint list.
  2. REQUEST DETAILS: When the user visits the app a second time, he/she [current user] can see only his/her last submitted record in a Display form.
Power Apps Display Last Submitted Record For Current User in Display Form

Power Apps New Request Form:

1. Insert a new screen -> add a Power Apps Edit form, and set its DataSource property to the SharePoint list.

DataSource = 'IT Service Ticket'
get last item id in sharepoint list PowerApps

2. The Name and Email will take the current logged-in user name and email by default. These are the code below to get the Power Apps current logged-in user name and email ID:

Name Datacard: Default = User().FullName
Email Datacard: Default = User().Email
powerapps get latest record from sharepoint list

3. Add a Save icon and set its OnSelect property as:

OnSelect = SubmitForm(Form1);ResetForm(Form1);

Form1 = Edit form name