Enumerations

Last modified: August 20, 2024

Introduction

An enumeration defines a list of predefined values. Enumerations are used for the enumeration attribute type. For example, the status of an order can be Open, Closed, or In Progress. So, the enumeration for the order status will consist of three values: Open, Closed, and In_Progress.

An enumeration consists of one or more enumeration values. Each value represents one option. An attribute of the enumeration type can also represent an uninitialized state: for example, if you do not assign any status to an order, the order status will be empty.

Enumeration Properties

An enumeration has the following properties:

  • Name – The name of the enumeration.

  • Documentation - This can be used to explain to other developers about the enumeration. End-users cannot see this documentation.

  • Export level – Allows you to define access level to this document on the consumer (customer) side when developing an add-on module or a solution.

    Export level has the following values:

    • Hidden (default) – The document/element content is hidden from a consumer.
    • Usable – Consumers can use the enumeration in their apps.
  • Enumeration values – An enumeration has one or more enumeration values. Each value represents one of the options. For more information on enumeration values and their properties, see the Enumeration Value Properties section.

The following properties are only available when the enumeration is an external enumeration that is part of a consumed Odata service:

  • From service - This property shows the source of the enumeration and allows you to Detach the enumeration from the source if the source has been deleted.
  • Original name - The original name of the enumeration from the source.

Enumeration Value Properties

Enumeration value properties are described below:

Caption

This is the caption of an enumeration value is the text that the end-user sees for this enumeration value.

The caption can be changed and can contain any character. For example, In Progress is a valid caption even though it contains a space.

This is a translatable text. For more information, see Language Menu.

Name

This is the name of an enumeration value. It is a technical name of the value which is used to refer to the enumeration value in your app.

The name of an enumeration value must be a technical name, starting with a letter and only containing letters, digits, and underscores.

It cannot be a reserved word (click to see a list of reserved words)
  • _
  • abstract
  • assert
  • boolean
  • break
  • byte
  • case
  • catch
  • changedby
  • changeddate
  • char
  • class
  • con
  • const
  • context
  • continue
  • createddate
  • currentUser
  • default
  • do
  • double
  • else
  • empty
  • enum
  • extends
  • false
  • final
  • finally
  • float
  • for
  • goto
  • guid
  • id
  • if
  • implements
  • import
  • instanceof
  • int
  • interface
  • long
  • MendixObject
  • native
  • new
  • null
  • object
  • owner
  • package
  • private
  • protected
  • public
  • return
  • short
  • static
  • strictfp
  • submetaobjectname
  • super
  • switch
  • synchronized
  • this
  • throw
  • throws
  • transient
  • true
  • try
  • type
  • void
  • volatile
  • while

Image

This is an image selected for an enumeration value to be displayed in a data grid column.

To use the image in a data grid, set the enumeration format of the column to Image. For more information on data grid columns, see Grid Columns.

Creating an Enumeration

To create a new enumeration, do the following:

  1. In the App Explorer, right-click the module or a folder you want to add enumeration to and in the list of actions, select Add other > Enumeration.

  2. In the Add Enumeration dialog box, fill out the name of the enumeration.

  3. In the Enumeration dialog box, click New to create enumeration values:

    1. Fill out Name and Caption for an enumeration value. You can set Image for it if necessary. For more information on enumeration properties, see the Enumeration Properties section.

    2. Click OK to save the enumeration value.

  4. Repeat step 3 for every enumeration value that you want to create.

  5. Click OK to save the enumeration.

You have added a new enumeration to your app. You can use the same enumeration for different attributes of the enumeration type in your app.

Read More