Enum if else condition failing

0
I am trying to use if else condition and set string column on basis of enum value. So if Enum value is Male then string would be set to : ‘Male’ Gender is column part of entity Column1. Enum is part of another domain model which is used as enum for Gender column.   if $Column1/Gender != empty then  if $Shared.ENUM_Gender.Female then 'Female'   else if $Shared.ENUM_Gender.Male  then  'Male'       else     'Unknown' else empty The error i am getting while using this code is:
asked
2 answers
0

I think your code should look like:


if $Column1/Gender != empty then
   if $Column1/Gender = ENUM_Gender.Female then 'Female'
      else
   if $Column1/Gender = ENUM_Gender.Male then 'Male'     
      else 'Unknown'
else empty

answered
0

You can't reference the enum as you might do for a boolean attribute here. To access the ENUM you need the full equation (aka both sides).  So the enum attribute on your entity needs to be compared to a certain value

Try:
if $Shared.ENUM_Gender = Main.ENUM_Gender.Female

then 'Female’

 

^The above assumes the enum attribute is actually an Enumeration. if it's a string, then simply compare against the string of Female in that example.  “Main” is a placeholder for the module name, since you need the fully qualified name of the enum.

 

Additional tip: If you hit Ctrl + Space when typing out expressions, you can see some intelligent autocomplete suggestions where you'll be able to find your enum and can drill down to its value to use in expressions

answered