Enum Elements add Dynamically

Hi,

How to create elements in Enum Dynamically ?

– Moumita Das

hi,

there are no elements in NAV , are you sure , you wanted to post it to NAV forum ?

g.

It should be done only at design time and I suspect you are not writing a code generator. If you want to do such a thing at run time, you must use another approach.

If you’re not sure how to implement your requirements, try to describe them - somebody may be able to help you.

I want to create a dialog for reporting purpose.
In this dialog there are two dialog fields
i. Country
ii.State

Depending upon the value of country the state field should be populated.

All right, but that’s a completely different question. The solution won’t use any enums at all.

What you really need is to select only state records corresponding to the given country. In AX it means to select AddressCounty records with the given CountryRegionId.

The easiest thing would be to implement the dialog as a normal form and override the lookup() method for the State control. You don’t have to implement the lookup yourself, just call AddressState::lookupStateId() with the selected country ID.

related link to create elements in Enum Dynamically.