cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GhassSD
Helper III
Helper III

Get SharePoint list items without the last record

Dears,

 

How we can get all SharePoint list items without the last record using get Items ?

using filter query, order by, top count ?

 

Any idea

thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @GhassSD ,

The Get_item_3 has only one value returned (and only one), so I think is it better to replace the Apply_to_each_5 action (and subsequent action) with a Set_Variable action ( from my point of view the flow is more readable in this way):

Name: LastMix

Value: body('Get_Item_3')['value'][0]['Mix']

 

Regarding the Get_Items_2 and the values is returning, change the filter query to:

Mix eq 'variables('LastMix')' and ID lt body('Get_Item_3')['value'][0]['ID'] (this will exclude the last ID). if it doesn't work as expected use Mix eq 'variables('LastMix')' and ID lt 'body('Get_Item_3')['value'][0]['ID']' ( i'm not quite sure if the returned value for ID is number type or string one).

 

Also I don't think that you need the Apply_to_each_6 action if you want to check if there are any other tems as the last one. It's enough to check inside if clause the length( body('Get_Items_2')['value']) against 0. (this means that the filter found/not found at least one record with the same Mix column as the last item in list).

 

Hope it helps !

View solution in original post

5 REPLIES 5
jinivthakkar
Dual Super User
Dual Super User

@GhassSD what is the use case ? Why don't you want the last record ? How many items are present in the list ? 

Dear,

I have this Share Point list, I need to check if the last record in 'Mix' column exist already before in the list, so directly the LOETime should be updated in the last record to be 0.5 

4.JPG

 

In order to do this I need to create a flow that search in a SharePoint list for a special value without the last record inserted.

So I did my flow as below:

 

Getting the last record in Mix column:

5.JPG

 

6.JPG

 

Then getting the all list items that contain the last record in Mix:

 

7.JPG

 

9.JPG

 

Then Condition:

 

10.JPG

 

But 'Get Items 2' is giving all the record of the table in addition to the last record.

So the condition gives all the time true. 

So our issue now is to get SharePoint list items without the last record ?

 

Any idea ?

Thank you in advance

 

 

Hi @GhassSD ,

The Get_item_3 has only one value returned (and only one), so I think is it better to replace the Apply_to_each_5 action (and subsequent action) with a Set_Variable action ( from my point of view the flow is more readable in this way):

Name: LastMix

Value: body('Get_Item_3')['value'][0]['Mix']

 

Regarding the Get_Items_2 and the values is returning, change the filter query to:

Mix eq 'variables('LastMix')' and ID lt body('Get_Item_3')['value'][0]['ID'] (this will exclude the last ID). if it doesn't work as expected use Mix eq 'variables('LastMix')' and ID lt 'body('Get_Item_3')['value'][0]['ID']' ( i'm not quite sure if the returned value for ID is number type or string one).

 

Also I don't think that you need the Apply_to_each_6 action if you want to check if there are any other tems as the last one. It's enough to check inside if clause the length( body('Get_Items_2')['value']) against 0. (this means that the filter found/not found at least one record with the same Mix column as the last item in list).

 

Hope it helps !

Dear @gabibalaban ,

 

Yes it solved,

 

GhassSD_0-1612443781240.png

I calculate the length:

GhassSD_1-1612443985476.png

If not equal to 1 so the value already exist, so the condition :

GhassSD_2-1612444019118.png

 

Best Regards,

 

 

 

@GhassSD ,

 

I gave you the long way solution 😊 ... to show that you can filter a Sharepoint list using multiple criteria on the same query.

Yes, in terms of number of actions  and understandability (i don't know if a such word reallly exists)  your solution fits more the great to your needs.

 

Good luck ! 

 

 

Helpful resources

Announcements
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.

New Process Advisor Capabilities carousel.png

Read the blog for the latest news

Read the latest about new experiences and capabilities in the Power Automate product blog.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (3,676)