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

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (37,883)