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.
https://community.mendix.com/link/space/java-actions/ideas/105
Provides an Java action sample code calling microflow for each Enumeration value
// BEGIN USER CODE
HashMap<String, Object> params = new HashMap<>();
int i = 0;
Class enumClass = Class.forName(enumToIterate);
if (enumClass.isEnum()) {
for (Object o : enumClass.getEnumConstants()) {
i++;
params.put("Enum", o.toString());
params.put("SortIndex", i);
Core.execute(this.getContext(), microflow, params);
}
}
return true;
// END USER CODE
we have a process mapped to enums.
all I want to do is retrieve objects over Xpath from a previous process step.
so now I have a datagrid on the page for each process enum with conditional visibility.
would rather just have 1 datagrid
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
Please make this change, this would be very useful.
This would be really useful to have without having to use workarounds.
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.
Very useful. Please also implement the other 53(!) open ideas for improving the enumeration.
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!
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
A function which returns the next/previous value of an enumeration would be very welcome.
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.
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.