Good morning,
I have a test flow where I want to just retrieve the last record ID within the list. In theory, what I want is to find the last item and then the first item in the list, divide all of that by 4000 to find how many iterations I need to loop, and finally delete every single record from there, but let's take a step back and figure out my first problem.
I have a variable that I'm initliazing and within the array, I want to return the first ID with this code but it's currently not working:
Body('Get_items')[0]?['value']?['ID']
here's my current setup:
And here's the error that I'm receiving:
Any ideas on how to fix this?
Ahhh! The [0] was in the wrong place! Thanks for the help!
Hi @hnguy71 ,
I noticed that the expression you used seems to be incorrect.
Please try to get the last item using the expression below.
body('Get_items')?['value'][0]['ID']
Please try again.
Best Regards,
Hi @ScottShearer ,
that only gives me back a maximum number of 5000. I was able to accomplish this in a different way. I used an apply_to_each and since I only have 1 item, I'll set the last record variable to just that 1 ID.
From there I set a variable to see how many iterations I need to purge the entire list:
add(div(variables('_LastRecord'), 4000), 1)
And I'll likely create an array to loop through them but I got further than I expected. I don't have a large list to try this out on but haha so far it looks like it's working. Thanks for the help!
As I understand it, your first goal is to find out how many items are in the list. Here is an alternate approach:
The variable holds the total number of list items.
Remember to go to settings for the Get Items action and set pagination on and set the threshold to a max of 5000 unless you have a P2 license.
If you will be using a do until loop when you delete the items, remember to click "change limits" in the loop and set the count to a number tat makes sense - the default maximum loop limit is 60.