Just goto the Java action and select the enum you want to use. Then just commit this Java action. If you want to have it for multiple enums just copy the Java action and select the right enum for each copy. Then you can use this Java action:
Regards,
Ronald
Not sure how the CommunityCommons action works, but you can create your own very simple Java action to convert a string to enum.
Just create a new Java action with a string input parameter and the desired enum as output parameter. Next, deploy to eclipse, and open the java action in Eclipse (or any other editor), and simply return you input string:
That's it!
https://medium.com/mendix/customizing-java-actions-mendix-25ec5cc14f24 will give you a good explanation on how to customize this EnumerationFromString JA the right way.
Make sure that when you replace communitycommons.proxies.LogLevel with modulefolder.proxies.enumname, that the modulefolder name is lowercase.
Regards,
Roel
Hi Tim,
I think you used it almost right, except
Did you noticed the following the Community commons class
// Replace LogLevel.class by the proxy class for your Enumeration
Optional<LogLevel> result = Misc.enumFromString(LogLevel.class, toConvert);
My take on this is
I have a generic implementation with me which returns the translation value given the language. But if we want to return ENUM, then specific implementation is still needed.
Im still looking at how the above action has to be used with example, will keep you posted when I got to know it.
Excellent answers here! Thank you!
Hi, I’m trying to use the CC EnumerationToString java action. I duplicated the action and renamed it and placed it in my custom module. When I use the Java Action in my microflow, I’m using the correct string and enums as inputs but I’m getting the following error when trying to compile the Java to run the app locally:
…...\actions\EnumerationFromString_Countries.java:39: error: cannot find symbol
[javac] Optional<LogLevel> result = Misc.enumFromString(ENUM_Countries_PostCodeLookup, toConvert);
[javac] ^
[javac] symbol: variable ENUM_Countries_PostCodeLookup
[javac] location: class EnumerationFromString_Countries
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] 1 error
I suspect that the issue is I need to replace the LogLevel.class in the Java Action, but I’m not sure what to replace it with. I tried using my enum’s name but still got errors. My enum is ENUM_Countries_PostCodeLookup.
Your help will be much appreciated.
Hi, I’m trying to use the CC EnumerationToString java action. I duplicated the action and renamed it and placed it in my custom module. When I use the Java Action in my microflow, I’m using the correct string and enums as inputs but I’m getting the following error when trying to compile the Java to run the app locally:
…...\actions\EnumerationFromString_Countries.java:39: error: cannot find symbol
[javac] Optional<LogLevel> result = Misc.enumFromString(ENUM_Countries_PostCodeLookup, toConvert);
[javac] ^
[javac] symbol: variable ENUM_Countries_PostCodeLookup
[javac] location: class EnumerationFromString_Countries
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] 1 error
I suspect that the issue is I need to replace the LogLevel.class in the Java Action, but I’m not sure what to replace it with. I tried using my enum’s name but still got errors. My enum is ENUM_Countries_PostCodeLookup.
Your help will be much appreciated.