How to set an enum value based on a string value?

4
I have a string as input parameter. Based on this string I would like to set a certain enumeration value for a specific object. However, I cannot find a way to easily set this enumeration value based on this string value with an exact same name (my enumeration has over 20 values). Someone a suggestion?
asked
2 answers
3

Make a sub microflow that you feed the string into. In the submicroflow you have a series of gateways, each checking for a different enumeration value (aka the string) like 'Ferrari'.

Then have the microflow return an enumeration using your specific enum and have the gateways return their appropriate enum value (Cars.enumeration.Ferrari) if they return true.

answered
2

You could do it in Java.

Input = String (should be equal to Enum caption!)
Output = Enumerator

Code example (Enum = KavelKavelTypeEnum, values = Prijskavel, Volumekavel)

    if (KavelKavelTypeEnum.Prijskavel.getCaption() == "MeegegevenString") {
        return KavelKavelTypeEnum.Prijskavel;
    } else if (KavelKavelTypeEnum.Volumekavel.getCaption() == "MeegegevenString") {
        return KavelKavelTypeEnum.Volumekavel;
    } else {
        return null;
    }
answered