Can I use a switch to Map to an enumeration from imported string variables?

0
Hello,  Newbie to Mendix here and I’m following the Crash course learning path. I’m Interacting with data and want to transform Import variables : String values are imported and transformed to my new enumeration (Gender and Jobtitle). In the course you transform the import variables with a Microflow using a simple decision: ($JobTitle = ‘Doctor’) Now I was wondering how this would work out in a real project where hospitals can have more than a 100 jobtitles (staff, management, external contractors,...). How would I implement that? Would I need to add a new decision in my microflow after each possible enumvalue check? Or can I do this more compact, like with a sort of switch where I can combine the checks in one decision? Ps: making a new rule with a ton of decisions with each their return value is not what I look for. But will be accepted if it’s the only possible way to go.
asked
3 answers
2

It is possible to use an if/else statement in your decision. However for debugging and readibility reasons, it would be best to model it out fully with a check for every value. 

answered
1

For reasonable sized enumerations Lennart's right. For maintainabillity purposes etc.

If you want to go full out on enums like your hospital example your probably best of writing a Java action specifically for this. See https://www.baeldung.com/java-string-to-enum for an example of this.

answered
1

Hi, maybe the “Appronto Common” module has the function you need. “ParseStringToEnum”

answered