How to retrieve the last object in a list? - Mendix Forum

How to retrieve the last object in a list?



In Retrieve in your Microflow you can set First as option to get the first value in your list, but how do you get the last value ? For Xpath I know that you can use last() function but I dont think this works in Mendix.




2 answers

Last object depends on the sorting order, by what order do you want to get the last object?
You can set the sorting and offset options to retrieve last object.
Another way if you already have the list, sort it so that it is inverted and last object comes first. Now take the head of the list using list operation and you have the last object


There is a list-app in the AppStore,,  which grants you some more ways to handle lists. One of them being retrieving the top-n items of a list. It does not give you a way to retrieve the last item of a list, but sorting might handle that.