Drop - down widget

Hi friends, I am having two questions: i) How can I configure a drop - down field in such a way that in caption I want to see the names but the values must be integer type (that will store in the data base). For eg: Caption Value to be stored in database Open 1 Processed 2 ii) How can I create a integer type enumeration in mendix.
3 answers

You can create an enumeration with values like

Value 1


Value 2


Value 3


And then in your logic you can extract a numeric representation of the enumeration by doing this and storing it in an integer attribute.


You could even replace the enumeration to an entity with both display value and integer value. In the form, simply replace your drop-down with a reference selector and you're set. Upside is that this allows you to configure values without having to redeploy. Downside is obviously that you have to populate the 'enumeration entity' (in the after-start-up, for instance) before you application will function.


You can use the getCaption function to get the value of the Enum. See this page for more info