I'm trying to get the 2nd last item from a SharePoint list.
- a flow is triggered when a new item is added to a SharePoint List.
- I want to add a number to the new item that is one larger than the previous item (essentially a tracker ID)
- so my flow is triggered by 'when an item is created'
- I'm then initialising a variable (which I want to set to ID number from the previous final list item).
Can you advise?
Thanks in advance
I suspect the easiest way would be to go Current Item ID (SharePoint's auto-generated ID, that is) minus 1, and then use that number as the ID for the "second to last item". From there you can grab whatever you need from the item and update the custom ID.
Would that work? Unless there's a constant deletion of items from this library making the ID not trustworthy, I think it would do the trick.
(My other comment is that if you are generating a schema for documents / files, it can be good to have a central place where all schemas are managed, in a list, and makes this kind of thing a bit easier / cleaner - you just query the list of the schema you want to use, get the last ID used, and increase it by 1, then update the file and the schema tracker. Fun document control stuff!)
this seems like a very elegant solution - many thanks for suggesting it.
I'll be trying it over the next few days and will make sure to reply if it works.
I'm failing at how to actually do the 'minus 1' activity. I'm trying to do a get item with an ODATA filter - is this the correct approach?
Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.