Drop - down widget

0
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.
asked
3 answers
1

You can create an enumeration with values like

Value 1

_1

Value 2

_2

Value 3

_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.

parseInteger(replaceAll(getKey($EntityName/EnumerationAttributeName),'_',''))
answered
4

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.

answered
0

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

answered