If you want to avoid the loop function you can also create a variable (integer) counter and add the first item on the list and then add one to the counter. Go back with a merge activity until you reached 5 and then continue?
Otherwise apply the filter in a constraint while retrieving 5 objects. You need some sort of variables to determine where you want to slice the list I suppose
Hi Klaustin,
I created a java action a while ago for this purpose, which you can use in microflows.
If you want to use it a nanoflow, you would have to create a similar Javascript Action.
Please check out the code below.
Java action Slice
General tab
Type parameter tab
java code
@java.lang.Override
public java.util.List<IMendixObject> executeAction() throws Exception
{
// BEGIN USER CODE
int startValue = Start != null ? Start.intValue() : 0;
int endValue = End != null ? End.intValue() : List.size();
return List.subList(startValue, endValue);
// END USER CODE
}
There are no existing methods, so you have to write your own javaaction to implement the logicThere are no existing methods, so you have to write your own javaAction to implement the logic
@op here
if your case is exactly slicing the first 5 items in a list, there is actually a Java Action called ‘List Top’. Horrible naming, but whatever. Otherwise follow @Nils Klatter answers’ (probably on top of this answer)