How to reverse a list of records in Microflow?

Hi all, I am retrieving a list of records from data base( without sorting). Now I want to reverse the list. For example, retrieved list contains {B, D, E, A, C }. Now I want this list to be reversed like { C, A, E, D, B }. How can I do this in a microflow? Please give me an idea how I can approch this. Thanks in advance.   Thanks, Venkat.
5 answers

Working solution for reversing any Objectlist using a microflow, recursively calling a sub_microflow.

This microflow

Recursively calls this sub_microflow:

Endresult will be that the OrdersReversed contain the same objectlist as Orders only reversed.

You can also checkout or in the app store MyReversingMicroflowWidget



If you add an integer attribute 'sort', you could loop through the list and start with setting the first value to -1. Then subtract 1 from your counter, so the next item gets -2. Then, after the loop, you can (list operation) sort the list on the attribute 'sort', and it will place the lowest value first.


No clean way yet, but what you can do is:

- create a parameter fill it with action list -head

- create a second parameter fill it with action list -tail

- pass those two to a submicroflow and with ActionList Union , 

See for a start. You will have to make all steps after and including "Tail Empty" into a recursive calling subflow.

NB. With a big enough list, this will for sure give you performance issues, as recursive actions tend to take up memory and you wil be passing the same data down and up in your calls.


I got solution for this question by creating a java action which reverses the list. The below one is my Microflow. 


And here is the java code for java action.


// This file was generated by Mendix Modeler.
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
// Special characters, e.g., é, ö, à, etc. are supported in comments.

package test.actions;

import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.webui.CustomJavaAction;
import com.mendix.systemwideinterfaces.core.IMendixObject;

public class ReverseInquiryProductList extends CustomJavaAction<java.lang.Boolean>
    private java.util.List<IMendixObject> __InputList;
    private java.util.List<texisle.proxies.InquiryProduct> InputList;
    private java.util.List<IMendixObject> __OutputList;
    private java.util.List<texisle.proxies.InquiryProduct> OutputList;

    public ReverseInquiryProductList(IContext context, java.util.List<IMendixObject> InputList, java.util.List<IMendixObject> OutputList)
        this.__InputList = InputList;
        this.__OutputList = OutputList;

    public java.lang.Boolean executeAction() throws Exception
        this.InputList = new java.util.ArrayList<texisle.proxies.InquiryProduct>();
        if (__InputList != null)
            for (IMendixObject __InputListElement : __InputList)
                this.InputList.add(texisle.proxies.InquiryProduct.initialize(getContext(), __InputListElement));

        this.OutputList = new java.util.ArrayList<texisle.proxies.InquiryProduct>();
        if (__OutputList != null)
            for (IMendixObject __OutputListElement : __OutputList)
                this.OutputList.add(texisle.proxies.InquiryProduct.initialize(getContext(), __OutputListElement));

        // BEGIN USER CODE
            if(__InputList !=null)
                for(int i=__InputList.size()-1;i>=0;i--){
            return true;
        catch(Exception e){
            return false;
        // END USER CODE

     * Returns a string representation of this action
    public java.lang.String toString()
        return "ReverseInquiryProductList";






Hi guys I need to reverse a string function in mendix can anybody give some idea about it?

I created two entity one is persistable (with the name Input) Non- persistable entity name (Result)

What ever values  I give in Input Attribute the value has to be reversed? anybody Answer for this