How to Xpath retrieve, compare string value to a enumeration value.

1
Like the topic says, I'm trying to identify an enumeration value by comparing it to a string. While doing an entity retrieve. The xpath should limit the entity where the string = enumeration value. How do I do this?
asked
2 answers
1

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.

answered
1

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."

answered