cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lui
Helper IV
Helper IV

Get items returning more than 1 item

I'm running to an issue where I'm running a Get items action for a sharepoint list and just want it to return one item.
Top Count = 1 

Pagination = 20,000

 

However, I keep getting a return of two items. It seems like top count doesn't work. Also, how can I just get the first item to return? I believe there's an expression I can use in the apply to each.

Objective:

I'm trying to capture the ID for the first item with a variable.

 

Get_Items.png

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User
Dual Super User

So here is what I think is going on.  Turning on Pagination will divide up the records into paged groups and apply your OData filter to each group.  That's why you are getting 2 items returned.  They are the top item from each page.

 

But when using an OData query you don't need to worry about pagination unless you are returning more records than the max record count. This is because the query is actually evaluated on the server.  So in your case the query will never return more than one record, but it will return up to one record for each page of results.

 

I ran a test on a large list I have with 5,101 records in it and it worked fine only returning one record even with pagination turned off.



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

View solution in original post

5 REPLIES 5
ScottShearer
Super User
Super User

@lui 

I just ran a quick test and Top count dies work for me as designed.

Try turning pagination off.  I don't believe that it should impact your results.

 

 

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

Scott

I need to since I have more than 5000 items in the SP list. Is it possible to add expression on the Apply to each step to get/select the first item?

@lui 

The 5000 limit refers to the fact that SharePoint will return a maximum of 5000 items.  You are filtering your results and limiting to 1 on the server side.  Therefore, pagination should not be necessary (you are returning a single item).

@Pstork1 would you care to chime in?

 

 

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

Scott

@ScottShearer doesn't pagination allow us to grab more than 5000 times before the filter?

The reason I began to use pagination because this sharepoint list (consists of 10000+ items) was not returning any items. Let's say I need two items to return: ID 100 and ID 10000. Without Pagination, the get items wouldnt return both regardless of the filter. Is this not correct?

Pstork1
Dual Super User
Dual Super User

So here is what I think is going on.  Turning on Pagination will divide up the records into paged groups and apply your OData filter to each group.  That's why you are getting 2 items returned.  They are the top item from each page.

 

But when using an OData query you don't need to worry about pagination unless you are returning more records than the max record count. This is because the query is actually evaluated on the server.  So in your case the query will never return more than one record, but it will return up to one record for each page of results.

 

I ran a test on a large list I have with 5,101 records in it and it worked fine only returning one record even with pagination turned off.



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

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.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Users online (2,717)