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.

Pstork1
Dual Super User
Dual Super User

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.
Pstork1
Dual Super User
Dual Super User

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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,611)