Hi,
Retrieve the last object directly from database, select first in Range and sort the records(add the attribute accordingly) in descending order as shown below
Or
If you have the list,sort it and get the head object using list operations and delete the record
Hope it helps!!!
Hi Ablikim,
You could sort the list to invert it. And then use the list operation Head. Which gets the first object of the list.
cheers
Hi Ablikim,
You can reach the last element of a list using a Loop like:
Or By Sorting the content, If you are retriving the data from database,
Just sort Reversed by a desired field “Descending” then just delete it.
Best regarts !
Or by java action:
Input is a list of at least one element (it cannot return a non initialized object, so you need to check for empty lists before calling this action). Returns the last element of the list.
public IMendixObject executeAction() throws Exception
{
// BEGIN USER CODE
int listLength = InputList.size();
if( listLength == 0 ){
throw new com.mendix.systemwideinterfaces.MendixRuntimeException("Cannot retrieve last element from empty list");
}
IMendixObject lastObjectInList = InputList.get( listLength - 1 );
return lastObjectInList;
// END USER CODE
}
So say you have a list with say 3 contacts, Bernard, Charles and Alex and you want the last name added to that list, you call the java action and it will give you the last item of the given list. If needed, you can ‘pop’ the element as well by removing it from the list.