Read enumerations into list

2
Hi is it possible to read enumerations key/value pairs in a list? Just like a retrieve list from database?   Background: Want to parse an XML/XLS/REST input and it might be unformatted (“in work”/”In Work”) MX Refelcetion doesn’t offer much, but maybe there is a way? Best would be even with multi language values of the enum caption. MS Version 9.18.0 thanks Stefan
asked
5 answers
7

Hi Stefan Mayer, it's possible you can download the community common module and use "EnumerationFromString" java action, open the java action and change the return type to your enum value and then use it in microflow and pass the string value into it and it will return the matched value from the enum

answered
0

Hi Stefan,

 

Marcel Groeneweg has answered this already using Mendix Reflection: https://forum.mendix.com/link/questions/104417

 

Regards

answered
0

Thanks @Martijn

Indeed I was able to retrieve all ‘reflected’ Enumerations and their captions.

However my question was not precise.

I actually have a parsed value in String format, with support of MX reflection I can now iterate on the Enumerations. Now I need a Enumeration value (Variable of the Enum type) as a return value. How can I select it dynamically based on the reflection or from the Enumeration.

I’m looking for something like getKey(Enum) but rather like: getEnum(key)

 

thanks

answered
0

Thanks @Emad

Yes that is exactly what I was looking for…

Edited the Java file to use my Enumeration Java class and it was all set

answered
0

For those who don't want to use model reflection or the java action:

This can also be achieved bij wrapping your string list in json and using an import mapping to convert it to a list of enum values

answered