You can build a List of entities with these values in using Java, but this is not particularly elegant.
Assuming you have an ENUM called ENUM_Test in MyFirstModule, and you are return an entity of type ENUMValues that has Caption and Name attributes, you can create a Java Action with the following code.
// BEGIN USER CODE
List<IMendixObject> list = new ArrayList<IMendixObject>();
List<myfirstmodule.proxies.ENUM_Test> values = new ArrayList<myfirstmodule.proxies.ENUM_Test>(Arrays.asList(myfirstmodule.proxies.ENUM_Test.values()));
for (myfirstmodule.proxies.ENUM_Test enum_test : values) {
myfirstmodule.proxies.ENUMValues ev = new myfirstmodule.proxies.ENUMValues(this.getContext());
ev.setCaption(enum_test.getCaption());
ev.setName(enum_test.name());
list.add(ev.getMendixObject());
}
return list;
// END USER CODE
Unfortunately, there is not a straightforward way to iterate over the values of an enum.
In the past, I have created a small helper entity with one attribute using the enum. Then I populate that entity with one object for each enum value. Then you can retrieve all of the objects in the entity and iterate over that. This method takes a bit of effort, but will enable you to iterate over an enum.
You can use getCaption(Enum) to get the caption of an enum.
If you want to select an enum you can just use a dropdown to get a list of those.
Thanks for your answer,
I am looking to create a list of enum values So that I can use in the microflow for iteration.
I don't know if that works. You can use a split to get a flow from every Enum option, maybe you can do you logic after all of those flows?
Hiii Sanskruti, to use enum in microflow you can use decision activity and pass each value of enum to the flow