Loop through Enum in Microflow - Mendix Forum

Loop through Enum in Microflow

168

Adding the ability in a microflow to be able to loop through, or find previous/next values in an Enumeration.  Would assume Enum is sequential when it is built.

asked
10 answers

I’ve published a module to transform an enumeration into a list, so you can make a loop in a microflow.

https://marketplace.mendix.com/link/component/211444

 

Created

Please make this change, this would be very useful.

Created

This would be really useful to have without having to use workarounds.

Created

Three years later, but since we are working with version 7.23 still running into the same issue.
Thanks for the workarounds but indeed this is something that is very good to add.

Created

Very useful. Please also implement the other 53(!) open ideas for improving the enumeration.

Created

Would be very useful to have. The suggestion of @Rob Bond is useful, but if you have a new enum value, you have to expand all these kind of splits. The idea of @Bart Poelmans is nice, but for most Mendix developers a bit complex. So, yes I support this idea!

Created

Implement a Java action (requires an IMendixObject):

var obj_imx=com.mendix.core.Core.instantiate(root.getContext(),"Monitor.Action");
var obj_met=obj_imx.getMetaObject();
var obj_mp=obj_met.getMetaPrimitive('Action');
var obj_metaenum=obj_mp.getEnumeration();
var arr_enumv=obj_mp.getEnumValues();

console.log('----------------------------------------');
console.log('String:');
console.log('----------------------------------------');
arr_enumv.forEach(
    function(obj_enum){
        console.log(obj_enum);
    }
);
console.log('----------------------------------------');
console.log('IMetaEnumValue:');
console.log('----------------------------------------');
var arr_metaenumv=obj_metaenum.getEnumValues();
arr_metaenumv.forEach(
    function(obj_enum){
        console.log(arr_metaenumv[obj_enum].getI18NCaptionKey());
        console.log(arr_metaenumv[obj_enum].getIdentifier());
        console.log(arr_metaenumv[obj_enum].getImage());
    }
);

* Nashorn version

Created

A function which returns the next/previous value of an enumeration would be very welcome. 

Created

Good suggestion. Especially usefull when you want to have some master data based on enumeration values. I always use the following wrokaround.

Retrieve from MxModelReflection the Enum values and use the iterator. Within the iterator, I get the enum value from a String using a Java action. String in -> Return Enum.

Now you will have each enum value in an iterator and you can do with it what you like.

Hope this is a nice workaround for you now.

Created

You probably already know this, but if you use the exclusive split action on an enumeration, you get one branch for each value of the enumeration plus empty.  If you have a sub microflow that does whatever you would put into your enumeration iteration loop, with the enumeration as one of the input values, then you can accomplish something like what you propose.

I agree that your proposal would be cleaner, but just in case you are struggling now this might help.

Created