cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
moelhag
Microsoft
Microsoft

Display user's last entry in editable form (connected to SP)

So i have a form where i ask my users to enter hours (to show how busy they will be in the next period). I want this form to be evergreen and editable. Due to their capacity & hours allotted to different areas changing throughout the week. There are two filters for this form, user, and work period.

 

When a form is submitted, it goes into a SharePoint list. I want a user to be able to go back into the form, and edit a specific periods hours. This would require the form to display their last entry, with the ability to edit, connected to the SP list. I was told, 'LastSubmit' wouldn't work in this case, due that function only showing last submitted entry in the current session. How would i go about this? Would I have to do an onStart Collection of the current users last entry into the SP data source?

 

Any ideas?

 

The SharePoint list has these columns

 

Name-WorkPeriod-WorkHrs-OutofOfficeHours-TrainingHours-OtherAdministrativeHours

 

-Each of these columns is editable in the PowerApp forms.

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User II
Super User II

Hi @moelhag 

All SharePoint lists have a hidden ID column.  Filter the list by the User and then sort it by the ID, descending and use First() to select the most recent record.   If you create a variable in the OnStart property of your app like Set(username,User().FullName) and set the form's datasource is YourList and the following is the Item property

 

First(Sort(Filter(YourList,Name=username),ID,Descending))

 

by using the variable username,  instead of User().FullName in the formula, you should avoid delegation issues. Also, using First(Sort( will avoid delegation problems and continue to work even if your list exceeds the maximum number of items, ie 500 or 2000. Last() and Max() are not delegatable in SharePoint and will give incorrect results if the list is more than the item limit. 

View solution in original post

1 REPLY 1
Drrickryp
Super User II
Super User II

Hi @moelhag 

All SharePoint lists have a hidden ID column.  Filter the list by the User and then sort it by the ID, descending and use First() to select the most recent record.   If you create a variable in the OnStart property of your app like Set(username,User().FullName) and set the form's datasource is YourList and the following is the Item property

 

First(Sort(Filter(YourList,Name=username),ID,Descending))

 

by using the variable username,  instead of User().FullName in the formula, you should avoid delegation issues. Also, using First(Sort( will avoid delegation problems and continue to work even if your list exceeds the maximum number of items, ie 500 or 2000. Last() and Max() are not delegatable in SharePoint and will give incorrect results if the list is more than the item limit. 

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,506)