cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Alexx1
Helper II
Helper II

Get the ID of last Item of Sharepoint and return it to Power Apps

Hello everybody!

I want to get the highest/largest ID in a SharePoint library (the most recent item submitted) and return it to PowerApps (in order to use it as a "counter").
Is it possible? I am trying with formulas such as "Max" or "Sort" but every time this error appears:

Sort.PNG

It says that "Delegation problem” because it takes to many items.
I just want the last Item created ID and return it to Power Apps (so I don't need the formula to run through all the lines...).

 

Any solution will be usefull! Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

@Alexx1 

The issue is that Sort in itself is delegable:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/delegation-overview

 

Sort Descending, turns the Table upside down such that the last item or ID becomes the first,

So you will not have issues picking the first from the sorted item which will be on top. That is it becomes number 1 no matter long the records.

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

View solution in original post

10 REPLIES 10
eka24
Super User
Super User

Sort and pick the first:

Last(Sort(Datasource,Descending)).CreatedID

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

First(Sort(Datasource,ID,Descending)).ID

@eka24 I think you meant to use this formula

First(Sort(Datasource,ID,Descending)).ID


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Alexx1
Helper II
Helper II

Thanks the answers!

 

It works but I still have the delegation problem, the same as before (with the yellow triangle), as you can see:

 

PPP.PNG

 

Any ideas? 

 

(For information, 'Non-conformité App is my data source (SharePoint Library))

 

 

Change it from Last TO First

First(Sort('Non-conformité App,ID,Desending)).ID

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

The warning is because First() can't be delegated.  But since you are sorting the list in Descending order, which can be delegated, you are assured that the highest Id is the First item in the list.  So it won't matter that First() isn't delegable in this case.  You only need the first item no matter how many there are.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi@Alexx1,

Based on the issue that you mentioned, do you want to remove the delegation warning?

Actually, the SharePoint ID field for a table is a number field in PowerApps. However, SharePoint only supports the equal "=" operator for delegation on an ID field.

 

071301.png

Best Regards,

Qi

Best Regards,
Qi

Thanks to everybody for the answers!

 

So I tested with "First" too and the warning still remains as you explained:

 

rrr.PNG

 

So are you telling me that it is normal, and that it doesn't matter if there is a warning? And that I will never have any problem with this, even if I have 10000 Items for example in the future?

 

Thanks! 😉

@Alexx1 

The issue is that Sort in itself is delegable:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/delegation-overview

 

Sort Descending, turns the Table upside down such that the last item or ID becomes the first,

So you will not have issues picking the first from the sorted item which will be on top. That is it becomes number 1 no matter long the records.

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

The picture below has 7200 records in SQL:

sort.JPG

 

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,692)