Switch Case in Mendix

I have a lot of decision activities that all check the same variable in my flow. Therefore I would like to combine this into one switch case statement. Unfortunately, this forum entry did not help me, as I could not find an exclusive split activity: https://forum.mendix.com/link/space/widgets/questions/126819 The solution with the enumeration did not work either.  How can I implement a switch case statement?
2 answers

Hi Sophia,

There is no built-in switch case statement like in some other programming languages. However, you can achieve similar functionality using other approaches. One common way to implement a switch case-like behavior in Mendix is by using an enumeration or a series of nested if-else statements.



Hi there,


You can use the decision activity that you would use for regular decisions:


In the case of an enumeration, you would put the enumeration attribute of the object as the expression:


In your case, I’d recommend using an enumeration, as Mendix only allows the condition of the decision to be a boolean or enumeration:


You can use a switch case when creating a variable and that variable could be used in a decision though:

Hope this helps,