Passing enum parameter value

I have to pass the enum parameter value to a class method. the receiving parameter have the same enum type.

But, the value did not pass it

eg.

costBooking.parmOccupantType(OccupantType.enumTypeValue());

Hi,

when you type your code, when opening the first bracket, the parm type and variable should appear in a tooltip, what’s displayed?

Regards,

Thomas

Hi. The problem is simple - the method .enumTypeValue() returns the enumID and not the current selection ! Whatever you select there, you will just get a system ID of you enum. But in your case you could use a following syntaxis:

costBooking.parmOccupantType(OccupantType.selection());

…BUT !!! there is a big but… you can use this approach only if you totally rely that the enum type that you are using there has all the element indexes in a row (I mean - element 1 in enum has id 1, element 2 has id 2 and so on…)

The best practice is to write an edit method for this reason if you have a non-bound field.

I don’t see the big but. ComboBox’es selection() method returns enum value, not the index. Where have experienced different behavior?

Martin, yes, you are right. Somehow I always thought that ComboBox selection ID returns the running ID of the selected combo box element (i.e., you click on first choice in combox, then index is 1, you click on the second choice and index is 2 and so on…), BUT (at this time it is a “BUT” (with one “T” however :slight_smile: ), AX does synchronise the ComboBox element IDs with enum IDs. Cool.