I would create a variable of the type Enumeration and build a large if then else construct that parses the string to the enumeration value . e.g.
if $inputString = '1' then MyFirstModule.Enum.1
else if $inputString = '2' then MyFirstModule.Enum.2
else empty
then use that enumeration variable in your retrieve.
Convert the string to an enumeration using Java, a solution from a colleague of mine:
"To convert a string value to an enumeration value we have used this Java action @ customer. Our enumeration is UsageConnector and contains over 100 values.
try {
return String.valueOf(UsageConnector.valueOf(this.StringValueOfEnumeration));
} catch (Exception e){
return null;
}
Very handy in case of enumerations with a large set of values."