Perform lookup on ENUM

Hi All,

I want to add a lookup method in a form. The lookup should display elements of ‘SysDimension’ ENUM. Please tell me how to write the lookup method.



You’ll get the lookup automatically if the field is based on the right enum type. Do you have any requirements that are not met by the default lookup?

Yes, I need to some operation on the field. The requirement is store multiple values of ‘SysDimension’ ENUM in a field. The ‘ReplaceOnLookup’ form control property is not available for ENUM field type. So I’, trying to write lookup which will show all the elements of ENUM.

Please suggest if it has any alternate solutions.



You could replicate the standard lookup by combobox:


but depending on what exactly you need, you may end with putting enum values to a temporary table and use the table lookup as usual. You can get enum value by a code like this:

SysDictEnum dictEnum = new SysDictEnum(enumnum(MyEnum));
int i;

for (i = 0; i < dictEnum.values(); i++)
    if (isConfigurationkeyEnabled(dictEnum.index2ConfigurationKey(i)))

By the way, if I wanted to store multiple enum values in a single field, I would save their indexes as flags in an integer number. For example, first and third elements would be represented by binary number 101 (5 in decimal set).

I created a lookup form and a temporary table. On click of lookup button, lookup form will add the elements from ‘SysDimension’ ENUM into the temp table (Create record). Then lookup will be displayed from temp table. It working fine.